1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-19 00:13:33 +00:00

- Upgrade to 2.1.

- Add patches (add -d argument for debug) to pcp tools (already
  committed to upstream).

PR:		ports/129182 (based on)
Submitted by:	mm
This commit is contained in:
Jun Kuriyama 2008-12-31 15:10:50 +00:00
parent fdd6beb59f
commit b31009c33b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=225065
64 changed files with 6556 additions and 236 deletions

View File

@ -6,10 +6,9 @@
#
PORTNAME= pgpool-II
PORTVERSION= 2.0.1
PORTREVISION= 2
PORTVERSION= 2.1
CATEGORIES= databases
MASTER_SITES= http://pgfoundry.org/frs/download.php/1521/
MASTER_SITES= http://pgfoundry.org/frs/download.php/1843/
MAINTAINER= kuriyama@FreeBSD.org
COMMENT= A connection pool server for PostgreSQL
@ -31,12 +30,19 @@ MAN8= pgpool.8
post-patch:
@${REINPLACE_CMD} -e 's|echo aout|echo elf|g' \
${WRKSRC}/configure
@${REINPLACE_CMD} -e 's| pg_config| ${LOCALBASE}/bin/pg_config|g' \
${WRKSRC}/sql/pgpool-recovery/Makefile
post-build:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE}
pre-install:
${MKDIR} ${DATADIR} ${EXAMPLESDIR}
post-install:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE} install
${INSTALL_DATA} ${WRKSRC}/sample/dist_def_pgbench.sql ${DATADIR}
${INSTALL_DATA} ${WRKSRC}/sample/replicate_def_pgbench.sql ${DATADIR}
.for f in pgpool_recovery pgpool_recovery_pitr pgpool_remote_start
${INSTALL_SCRIPT} ${WRKSRC}/sample/${f} ${EXAMPLESDIR}
.endfor

View File

@ -1,3 +1,3 @@
MD5 (pgpool-II-2.0.1.tar.gz) = fdfd023b1400ae85455e8274bf0cb502
SHA256 (pgpool-II-2.0.1.tar.gz) = f30ca8ec9ec30a277dbffb06a9d11510e22e24fb457267c568ed46b046708961
SIZE (pgpool-II-2.0.1.tar.gz) = 913792
MD5 (pgpool-II-2.1.tar.gz) = cf02f9358f46849bd526798868e13162
SHA256 (pgpool-II-2.1.tar.gz) = 8834b6ca01eab57d2c947c1016f164e0538e45242f1d3a3fa99932dae87ba890
SIZE (pgpool-II-2.1.tar.gz) = 932731

View File

@ -1,53 +0,0 @@
--- main.c.orig 2007-11-09 13:37:35.000000000 +0900
+++ main.c 2008-03-03 10:24:27.651654702 +0900
@@ -836,7 +836,13 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ char *host = "", *serv = "";
+ char hostname[NI_MAXHOST], servname[NI_MAXSERV];
+ if (getnameinfo(&addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0) == 0) {
+ host = hostname;
+ serv = servname;
+ }
+ pool_error("bind(%s:%s) failed. reason: %s", host, serv, strerror(errno));
myexit(1);
}
@@ -872,7 +878,7 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno));
myexit(1);
}
@@ -891,6 +897,12 @@
return fd;
}
+static void myunlink(const char* path)
+{
+ if (unlink(path) == 0) return;
+ pool_error("unlink(%s) failed: %s", path, strerror(errno));
+}
+
static void myexit(int code)
{
char path[POOLMAXPATHLEN];
@@ -917,10 +929,10 @@
POOL_SETMASK(&UnBlockSig);
}
- unlink(un_addr.sun_path);
- unlink(pcp_un_addr.sun_path);
+ myunlink(un_addr.sun_path);
+ myunlink(pcp_un_addr.sun_path);
snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
- unlink(path);
+ myunlink(path);
pool_shmem_exit(code);
exit(code);

View File

@ -0,0 +1,598 @@
Index: pcp/pcp.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.c,v
retrieving revision 1.7
diff -u -r1.7 pcp.c
--- pcp/pcp.c 8 Feb 2008 08:10:43 -0000 1.7
+++ pcp/pcp.c 29 Dec 2008 05:15:44 -0000
@@ -42,6 +42,11 @@
struct timeval pcp_timeout;
static PCP_CONNECTION *pc;
+#ifdef DEBUG
+static int debug = 1;
+#else
+static int debug = 0;
+#endif
static int pcp_authorize(char *username, char *password);
/* --------------------------------
@@ -62,9 +67,7 @@
if (pc != NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
return 0;
}
@@ -76,9 +79,7 @@
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -100,9 +101,7 @@
if (connect(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
close(fd);
errorcode = CONNERR;
return -1;
@@ -113,9 +112,7 @@
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -123,9 +120,7 @@
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not set socket option\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not set socket option\n");
close(fd);
errorcode = SOCKERR;
return -1;
@@ -136,9 +131,7 @@
hp = gethostbyname(hostname);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not retrieve hostname\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not retrieve hostname\n");
close(fd);
errorcode = HOSTERR;
return -1;
@@ -151,9 +144,7 @@
len = sizeof(struct sockaddr_in);
if (connect(fd, (struct sockaddr *) &addr, len) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
close(fd);
errorcode = CONNERR;
return -1;
@@ -163,9 +154,7 @@
pc = pcp_open(fd);
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not allocate buffer space\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not allocate buffer space\n");
close(fd);
return -1;
}
@@ -202,9 +191,7 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
@@ -243,14 +230,10 @@
pcp_write(pc, encrypt_buf, strlen(encrypt_buf)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -265,15 +248,11 @@
}
if (pcp_read(pc, buf, rsize - sizeof(int)))
return -1;
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'r')
@@ -284,9 +263,7 @@
return 0;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
errorcode = AUTHERR;
}
free(buf);
@@ -305,9 +282,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
return;
}
@@ -318,9 +293,7 @@
{
/* backend had closed connection already */
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
pcp_close(pc);
pc = NULL;
@@ -339,9 +312,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -352,14 +323,10 @@
pcp_write(pc, &mode, sizeof(char));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
return 0;
}
@@ -381,9 +348,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -393,14 +358,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -419,15 +380,11 @@
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'l')
@@ -466,9 +423,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -481,14 +436,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -507,15 +458,11 @@
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
free(buf);
return NULL;
@@ -578,9 +525,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -590,14 +535,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -615,15 +556,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -685,9 +622,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -700,14 +635,10 @@
pcp_write(pc, process_id, strlen(process_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
while (1)
{
@@ -727,15 +658,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -836,9 +763,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -848,14 +773,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
while (1) {
if (pcp_read(pc, &tos, 1))
@@ -874,15 +795,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -1166,9 +1083,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1181,14 +1096,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1206,15 +1117,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'd')
@@ -1249,9 +1156,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1264,14 +1169,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1289,15 +1190,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1334,9 +1231,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1349,14 +1244,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1374,15 +1265,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1398,3 +1285,15 @@
free(buf);
return -1;
}
+
+void
+pcp_enable_debug(void)
+{
+ debug = 1;
+}
+
+void
+pcp_disable_debug(void)
+{
+ debug = 0;
+}

View File

@ -0,0 +1,16 @@
Index: pcp/pcp.h
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.h,v
retrieving revision 1.3
diff -u -r1.3 pcp.h
--- pcp/pcp.h 29 Jan 2008 01:56:37 -0000 1.3
+++ pcp/pcp.h 29 Dec 2008 05:15:44 -0000
@@ -62,6 +62,8 @@
extern int pcp_attach_node(int nid);
extern void pcp_set_timeout(long sec);
extern int pcp_recovery_node(int nid);
+extern void pcp_enable_debug(void);
+extern void pcp_disable_debug(void);
/* ------------------------------
* pcp_error.c

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_attach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_attach_node.c
--- pcp/pcp_attach_node.c 29 Jan 2008 01:56:37 -0000 1.2
+++ pcp/pcp_attach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_attach_node - attach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_attach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_attach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_attach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_detach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_detach_node.c
--- pcp/pcp_detach_node.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_detach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_detach_node - detach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_detach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_detach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_detach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,104 @@
Index: pcp/pcp_node_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_count.c
--- pcp/pcp_node_count.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,53 +39,64 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int node_count;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);
@@ -112,8 +124,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_count - display the total number of nodes under pgpool-II's control\n\n");
- fprintf(stderr, "Usage: pcp_node_count timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_node_count [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_node_count -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_node_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_info.c
--- pcp/pcp_node_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
BackendInfo *backend_info;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,23 +88,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -132,8 +144,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_info - display a pgpool-II node's information\n\n");
- fprintf(stderr, "Usage: pcp_node_info timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_node_info [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_node_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,93 @@
Index: pcp/pcp_proc_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_proc_count.c
--- pcp/pcp_proc_count.c 29 Jan 2008 01:56:38 -0000 1.3
+++ pcp/pcp_proc_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,53 +40,64 @@
char pass[MAX_USER_PASSWD_LEN];
int process_count;
int *process_list = NULL;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_proc_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_proc_info.c
--- pcp/pcp_proc_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_proc_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -40,36 +41,47 @@
int processID;
ProcessInfo *process_info;
int array_size;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -77,23 +89,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- processID = atoi(argv[6]);
+ processID = atoi(argv[5]);
if (processID < 0)
{
errorcode = INVALERR;
@@ -142,8 +154,9 @@
usage(void)
{
fprintf(stderr, "pcp_proc_info - display a pgpool-II child process' information\n\n");
- fprintf(stderr, "Usage: pcp_proc_info timeout hostname port# username password PID\n");
+ fprintf(stderr, "Usage: pcp_proc_info [-d] timeout hostname port# username password PID\n");
fprintf(stderr, "Usage: pcp_proc_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,120 @@
Index: pcp/pcp_recovery_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_recovery_node.c
--- pcp/pcp_recovery_node.c 12 Mar 2008 04:53:51 -0000 1.3
+++ pcp/pcp_recovery_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,30 +87,30 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
-
+
pcp_set_timeout(timeout);
if (pcp_connect(host, port, user, pass))
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_recovery_node - recovery a node\n\n");
- fprintf(stderr, "Usage: pcp_recovery_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_recovery_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,119 @@
Index: pcp/pcp_stop_pgpool.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_stop_pgpool.c
--- pcp/pcp_stop_pgpool.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_stop_pgpool.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
char mode;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,29 +87,29 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- if (strlen(argv[6]) != 1)
+ if (strlen(argv[5]) != 1)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- mode = argv[6][0];
+ mode = argv[5][0];
if (mode != 's' && mode != 'f' && mode != 'i')
{
errorcode = INVALERR;
@@ -131,8 +143,9 @@
usage(void)
{
fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_stop_pgpool timeout hostname port# username password mode\n");
+ fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n");
fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,109 @@
Index: pcp/pcp_systemdb_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_systemdb_info.c
--- pcp/pcp_systemdb_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_systemdb_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
SystemDBInfo *systemdb_info;
int i, j;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6)
+ if (argc != 5)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,21 +88,21 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
if (pcp_connect(host, port, user, pass))
{
@@ -146,8 +158,9 @@
usage(void)
{
fprintf(stderr, "pcp_systemdb_info - display the pgpool-II systemDB information\n\n");
- fprintf(stderr, "Usage: pcp_systemdb_info timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_systemdb_info [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_systemdb_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,16 @@
Index: pool_sema.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_sema.c,v
retrieving revision 1.4
diff -u -r1.4 pool_sema.c
--- pool_sema.c 29 Jan 2008 01:56:36 -0000 1.4
+++ pool_sema.c 29 Dec 2008 05:15:44 -0000
@@ -82,7 +82,7 @@
if (semId < 0)
{
- pool_error("could not create semaphores: %s", strerror(errno));
+ pool_error("could not create %d semaphores: %s", numSems, strerror(errno));
return -1;
}

View File

@ -21,9 +21,13 @@ lib/libpcp.so
lib/libpcp.so.0
%%DATADIR%%/dist_def_pgbench.sql
%%DATADIR%%/pgpool.pam
%%DATADIR%%/replicate_def_pgbench.sql
%%DATADIR%%/system_db.sql
%%EXAMPLESDIR%%/pgpool_recovery
%%EXAMPLESDIR%%/pgpool_recovery_pitr
%%EXAMPLESDIR%%/pgpool_remote_start
share/postgresql/contrib/pgpool-recovery.sql
lib/postgresql/pgpool-recovery.so
@dirrmtry share/postgresql/contrib
@dirrm %%EXAMPLESDIR%%
@dirrm %%DATADIR%%

View File

@ -6,10 +6,9 @@
#
PORTNAME= pgpool-II
PORTVERSION= 2.0.1
PORTREVISION= 2
PORTVERSION= 2.1
CATEGORIES= databases
MASTER_SITES= http://pgfoundry.org/frs/download.php/1521/
MASTER_SITES= http://pgfoundry.org/frs/download.php/1843/
MAINTAINER= kuriyama@FreeBSD.org
COMMENT= A connection pool server for PostgreSQL
@ -31,12 +30,19 @@ MAN8= pgpool.8
post-patch:
@${REINPLACE_CMD} -e 's|echo aout|echo elf|g' \
${WRKSRC}/configure
@${REINPLACE_CMD} -e 's| pg_config| ${LOCALBASE}/bin/pg_config|g' \
${WRKSRC}/sql/pgpool-recovery/Makefile
post-build:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE}
pre-install:
${MKDIR} ${DATADIR} ${EXAMPLESDIR}
post-install:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE} install
${INSTALL_DATA} ${WRKSRC}/sample/dist_def_pgbench.sql ${DATADIR}
${INSTALL_DATA} ${WRKSRC}/sample/replicate_def_pgbench.sql ${DATADIR}
.for f in pgpool_recovery pgpool_recovery_pitr pgpool_remote_start
${INSTALL_SCRIPT} ${WRKSRC}/sample/${f} ${EXAMPLESDIR}
.endfor

View File

@ -1,3 +1,3 @@
MD5 (pgpool-II-2.0.1.tar.gz) = fdfd023b1400ae85455e8274bf0cb502
SHA256 (pgpool-II-2.0.1.tar.gz) = f30ca8ec9ec30a277dbffb06a9d11510e22e24fb457267c568ed46b046708961
SIZE (pgpool-II-2.0.1.tar.gz) = 913792
MD5 (pgpool-II-2.1.tar.gz) = cf02f9358f46849bd526798868e13162
SHA256 (pgpool-II-2.1.tar.gz) = 8834b6ca01eab57d2c947c1016f164e0538e45242f1d3a3fa99932dae87ba890
SIZE (pgpool-II-2.1.tar.gz) = 932731

View File

@ -1,53 +0,0 @@
--- main.c.orig 2007-11-09 13:37:35.000000000 +0900
+++ main.c 2008-03-03 10:24:27.651654702 +0900
@@ -836,7 +836,13 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ char *host = "", *serv = "";
+ char hostname[NI_MAXHOST], servname[NI_MAXSERV];
+ if (getnameinfo(&addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0) == 0) {
+ host = hostname;
+ serv = servname;
+ }
+ pool_error("bind(%s:%s) failed. reason: %s", host, serv, strerror(errno));
myexit(1);
}
@@ -872,7 +878,7 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno));
myexit(1);
}
@@ -891,6 +897,12 @@
return fd;
}
+static void myunlink(const char* path)
+{
+ if (unlink(path) == 0) return;
+ pool_error("unlink(%s) failed: %s", path, strerror(errno));
+}
+
static void myexit(int code)
{
char path[POOLMAXPATHLEN];
@@ -917,10 +929,10 @@
POOL_SETMASK(&UnBlockSig);
}
- unlink(un_addr.sun_path);
- unlink(pcp_un_addr.sun_path);
+ myunlink(un_addr.sun_path);
+ myunlink(pcp_un_addr.sun_path);
snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
- unlink(path);
+ myunlink(path);
pool_shmem_exit(code);
exit(code);

View File

@ -0,0 +1,598 @@
Index: pcp/pcp.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.c,v
retrieving revision 1.7
diff -u -r1.7 pcp.c
--- pcp/pcp.c 8 Feb 2008 08:10:43 -0000 1.7
+++ pcp/pcp.c 29 Dec 2008 05:15:44 -0000
@@ -42,6 +42,11 @@
struct timeval pcp_timeout;
static PCP_CONNECTION *pc;
+#ifdef DEBUG
+static int debug = 1;
+#else
+static int debug = 0;
+#endif
static int pcp_authorize(char *username, char *password);
/* --------------------------------
@@ -62,9 +67,7 @@
if (pc != NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
return 0;
}
@@ -76,9 +79,7 @@
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -100,9 +101,7 @@
if (connect(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
close(fd);
errorcode = CONNERR;
return -1;
@@ -113,9 +112,7 @@
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -123,9 +120,7 @@
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not set socket option\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not set socket option\n");
close(fd);
errorcode = SOCKERR;
return -1;
@@ -136,9 +131,7 @@
hp = gethostbyname(hostname);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not retrieve hostname\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not retrieve hostname\n");
close(fd);
errorcode = HOSTERR;
return -1;
@@ -151,9 +144,7 @@
len = sizeof(struct sockaddr_in);
if (connect(fd, (struct sockaddr *) &addr, len) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
close(fd);
errorcode = CONNERR;
return -1;
@@ -163,9 +154,7 @@
pc = pcp_open(fd);
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not allocate buffer space\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not allocate buffer space\n");
close(fd);
return -1;
}
@@ -202,9 +191,7 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
@@ -243,14 +230,10 @@
pcp_write(pc, encrypt_buf, strlen(encrypt_buf)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -265,15 +248,11 @@
}
if (pcp_read(pc, buf, rsize - sizeof(int)))
return -1;
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'r')
@@ -284,9 +263,7 @@
return 0;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
errorcode = AUTHERR;
}
free(buf);
@@ -305,9 +282,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
return;
}
@@ -318,9 +293,7 @@
{
/* backend had closed connection already */
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
pcp_close(pc);
pc = NULL;
@@ -339,9 +312,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -352,14 +323,10 @@
pcp_write(pc, &mode, sizeof(char));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
return 0;
}
@@ -381,9 +348,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -393,14 +358,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -419,15 +380,11 @@
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'l')
@@ -466,9 +423,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -481,14 +436,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -507,15 +458,11 @@
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
free(buf);
return NULL;
@@ -578,9 +525,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -590,14 +535,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -615,15 +556,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -685,9 +622,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -700,14 +635,10 @@
pcp_write(pc, process_id, strlen(process_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
while (1)
{
@@ -727,15 +658,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -836,9 +763,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -848,14 +773,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
while (1) {
if (pcp_read(pc, &tos, 1))
@@ -874,15 +795,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -1166,9 +1083,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1181,14 +1096,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1206,15 +1117,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'd')
@@ -1249,9 +1156,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1264,14 +1169,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1289,15 +1190,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1334,9 +1231,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1349,14 +1244,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1374,15 +1265,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1398,3 +1285,15 @@
free(buf);
return -1;
}
+
+void
+pcp_enable_debug(void)
+{
+ debug = 1;
+}
+
+void
+pcp_disable_debug(void)
+{
+ debug = 0;
+}

View File

@ -0,0 +1,16 @@
Index: pcp/pcp.h
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.h,v
retrieving revision 1.3
diff -u -r1.3 pcp.h
--- pcp/pcp.h 29 Jan 2008 01:56:37 -0000 1.3
+++ pcp/pcp.h 29 Dec 2008 05:15:44 -0000
@@ -62,6 +62,8 @@
extern int pcp_attach_node(int nid);
extern void pcp_set_timeout(long sec);
extern int pcp_recovery_node(int nid);
+extern void pcp_enable_debug(void);
+extern void pcp_disable_debug(void);
/* ------------------------------
* pcp_error.c

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_attach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_attach_node.c
--- pcp/pcp_attach_node.c 29 Jan 2008 01:56:37 -0000 1.2
+++ pcp/pcp_attach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_attach_node - attach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_attach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_attach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_attach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_detach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_detach_node.c
--- pcp/pcp_detach_node.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_detach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_detach_node - detach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_detach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_detach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_detach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,104 @@
Index: pcp/pcp_node_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_count.c
--- pcp/pcp_node_count.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,53 +39,64 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int node_count;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);
@@ -112,8 +124,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_count - display the total number of nodes under pgpool-II's control\n\n");
- fprintf(stderr, "Usage: pcp_node_count timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_node_count [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_node_count -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_node_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_info.c
--- pcp/pcp_node_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
BackendInfo *backend_info;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,23 +88,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -132,8 +144,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_info - display a pgpool-II node's information\n\n");
- fprintf(stderr, "Usage: pcp_node_info timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_node_info [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_node_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,93 @@
Index: pcp/pcp_proc_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_proc_count.c
--- pcp/pcp_proc_count.c 29 Jan 2008 01:56:38 -0000 1.3
+++ pcp/pcp_proc_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,53 +40,64 @@
char pass[MAX_USER_PASSWD_LEN];
int process_count;
int *process_list = NULL;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_proc_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_proc_info.c
--- pcp/pcp_proc_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_proc_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -40,36 +41,47 @@
int processID;
ProcessInfo *process_info;
int array_size;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -77,23 +89,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- processID = atoi(argv[6]);
+ processID = atoi(argv[5]);
if (processID < 0)
{
errorcode = INVALERR;
@@ -142,8 +154,9 @@
usage(void)
{
fprintf(stderr, "pcp_proc_info - display a pgpool-II child process' information\n\n");
- fprintf(stderr, "Usage: pcp_proc_info timeout hostname port# username password PID\n");
+ fprintf(stderr, "Usage: pcp_proc_info [-d] timeout hostname port# username password PID\n");
fprintf(stderr, "Usage: pcp_proc_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,120 @@
Index: pcp/pcp_recovery_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_recovery_node.c
--- pcp/pcp_recovery_node.c 12 Mar 2008 04:53:51 -0000 1.3
+++ pcp/pcp_recovery_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,30 +87,30 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
-
+
pcp_set_timeout(timeout);
if (pcp_connect(host, port, user, pass))
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_recovery_node - recovery a node\n\n");
- fprintf(stderr, "Usage: pcp_recovery_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_recovery_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,119 @@
Index: pcp/pcp_stop_pgpool.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_stop_pgpool.c
--- pcp/pcp_stop_pgpool.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_stop_pgpool.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
char mode;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,29 +87,29 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- if (strlen(argv[6]) != 1)
+ if (strlen(argv[5]) != 1)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- mode = argv[6][0];
+ mode = argv[5][0];
if (mode != 's' && mode != 'f' && mode != 'i')
{
errorcode = INVALERR;
@@ -131,8 +143,9 @@
usage(void)
{
fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_stop_pgpool timeout hostname port# username password mode\n");
+ fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n");
fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,109 @@
Index: pcp/pcp_systemdb_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_systemdb_info.c
--- pcp/pcp_systemdb_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_systemdb_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
SystemDBInfo *systemdb_info;
int i, j;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6)
+ if (argc != 5)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,21 +88,21 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
if (pcp_connect(host, port, user, pass))
{
@@ -146,8 +158,9 @@
usage(void)
{
fprintf(stderr, "pcp_systemdb_info - display the pgpool-II systemDB information\n\n");
- fprintf(stderr, "Usage: pcp_systemdb_info timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_systemdb_info [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_systemdb_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,16 @@
Index: pool_sema.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_sema.c,v
retrieving revision 1.4
diff -u -r1.4 pool_sema.c
--- pool_sema.c 29 Jan 2008 01:56:36 -0000 1.4
+++ pool_sema.c 29 Dec 2008 05:15:44 -0000
@@ -82,7 +82,7 @@
if (semId < 0)
{
- pool_error("could not create semaphores: %s", strerror(errno));
+ pool_error("could not create %d semaphores: %s", numSems, strerror(errno));
return -1;
}

View File

@ -21,9 +21,13 @@ lib/libpcp.so
lib/libpcp.so.0
%%DATADIR%%/dist_def_pgbench.sql
%%DATADIR%%/pgpool.pam
%%DATADIR%%/replicate_def_pgbench.sql
%%DATADIR%%/system_db.sql
%%EXAMPLESDIR%%/pgpool_recovery
%%EXAMPLESDIR%%/pgpool_recovery_pitr
%%EXAMPLESDIR%%/pgpool_remote_start
share/postgresql/contrib/pgpool-recovery.sql
lib/postgresql/pgpool-recovery.so
@dirrmtry share/postgresql/contrib
@dirrm %%EXAMPLESDIR%%
@dirrm %%DATADIR%%

View File

@ -6,10 +6,9 @@
#
PORTNAME= pgpool-II
PORTVERSION= 2.0.1
PORTREVISION= 2
PORTVERSION= 2.1
CATEGORIES= databases
MASTER_SITES= http://pgfoundry.org/frs/download.php/1521/
MASTER_SITES= http://pgfoundry.org/frs/download.php/1843/
MAINTAINER= kuriyama@FreeBSD.org
COMMENT= A connection pool server for PostgreSQL
@ -31,12 +30,19 @@ MAN8= pgpool.8
post-patch:
@${REINPLACE_CMD} -e 's|echo aout|echo elf|g' \
${WRKSRC}/configure
@${REINPLACE_CMD} -e 's| pg_config| ${LOCALBASE}/bin/pg_config|g' \
${WRKSRC}/sql/pgpool-recovery/Makefile
post-build:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE}
pre-install:
${MKDIR} ${DATADIR} ${EXAMPLESDIR}
post-install:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE} install
${INSTALL_DATA} ${WRKSRC}/sample/dist_def_pgbench.sql ${DATADIR}
${INSTALL_DATA} ${WRKSRC}/sample/replicate_def_pgbench.sql ${DATADIR}
.for f in pgpool_recovery pgpool_recovery_pitr pgpool_remote_start
${INSTALL_SCRIPT} ${WRKSRC}/sample/${f} ${EXAMPLESDIR}
.endfor

View File

@ -1,3 +1,3 @@
MD5 (pgpool-II-2.0.1.tar.gz) = fdfd023b1400ae85455e8274bf0cb502
SHA256 (pgpool-II-2.0.1.tar.gz) = f30ca8ec9ec30a277dbffb06a9d11510e22e24fb457267c568ed46b046708961
SIZE (pgpool-II-2.0.1.tar.gz) = 913792
MD5 (pgpool-II-2.1.tar.gz) = cf02f9358f46849bd526798868e13162
SHA256 (pgpool-II-2.1.tar.gz) = 8834b6ca01eab57d2c947c1016f164e0538e45242f1d3a3fa99932dae87ba890
SIZE (pgpool-II-2.1.tar.gz) = 932731

View File

@ -1,53 +0,0 @@
--- main.c.orig 2007-11-09 13:37:35.000000000 +0900
+++ main.c 2008-03-03 10:24:27.651654702 +0900
@@ -836,7 +836,13 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ char *host = "", *serv = "";
+ char hostname[NI_MAXHOST], servname[NI_MAXSERV];
+ if (getnameinfo(&addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0) == 0) {
+ host = hostname;
+ serv = servname;
+ }
+ pool_error("bind(%s:%s) failed. reason: %s", host, serv, strerror(errno));
myexit(1);
}
@@ -872,7 +878,7 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno));
myexit(1);
}
@@ -891,6 +897,12 @@
return fd;
}
+static void myunlink(const char* path)
+{
+ if (unlink(path) == 0) return;
+ pool_error("unlink(%s) failed: %s", path, strerror(errno));
+}
+
static void myexit(int code)
{
char path[POOLMAXPATHLEN];
@@ -917,10 +929,10 @@
POOL_SETMASK(&UnBlockSig);
}
- unlink(un_addr.sun_path);
- unlink(pcp_un_addr.sun_path);
+ myunlink(un_addr.sun_path);
+ myunlink(pcp_un_addr.sun_path);
snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
- unlink(path);
+ myunlink(path);
pool_shmem_exit(code);
exit(code);

View File

@ -0,0 +1,598 @@
Index: pcp/pcp.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.c,v
retrieving revision 1.7
diff -u -r1.7 pcp.c
--- pcp/pcp.c 8 Feb 2008 08:10:43 -0000 1.7
+++ pcp/pcp.c 29 Dec 2008 05:15:44 -0000
@@ -42,6 +42,11 @@
struct timeval pcp_timeout;
static PCP_CONNECTION *pc;
+#ifdef DEBUG
+static int debug = 1;
+#else
+static int debug = 0;
+#endif
static int pcp_authorize(char *username, char *password);
/* --------------------------------
@@ -62,9 +67,7 @@
if (pc != NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
return 0;
}
@@ -76,9 +79,7 @@
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -100,9 +101,7 @@
if (connect(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
close(fd);
errorcode = CONNERR;
return -1;
@@ -113,9 +112,7 @@
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -123,9 +120,7 @@
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not set socket option\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not set socket option\n");
close(fd);
errorcode = SOCKERR;
return -1;
@@ -136,9 +131,7 @@
hp = gethostbyname(hostname);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not retrieve hostname\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not retrieve hostname\n");
close(fd);
errorcode = HOSTERR;
return -1;
@@ -151,9 +144,7 @@
len = sizeof(struct sockaddr_in);
if (connect(fd, (struct sockaddr *) &addr, len) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
close(fd);
errorcode = CONNERR;
return -1;
@@ -163,9 +154,7 @@
pc = pcp_open(fd);
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not allocate buffer space\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not allocate buffer space\n");
close(fd);
return -1;
}
@@ -202,9 +191,7 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
@@ -243,14 +230,10 @@
pcp_write(pc, encrypt_buf, strlen(encrypt_buf)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -265,15 +248,11 @@
}
if (pcp_read(pc, buf, rsize - sizeof(int)))
return -1;
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'r')
@@ -284,9 +263,7 @@
return 0;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
errorcode = AUTHERR;
}
free(buf);
@@ -305,9 +282,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
return;
}
@@ -318,9 +293,7 @@
{
/* backend had closed connection already */
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
pcp_close(pc);
pc = NULL;
@@ -339,9 +312,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -352,14 +323,10 @@
pcp_write(pc, &mode, sizeof(char));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
return 0;
}
@@ -381,9 +348,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -393,14 +358,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -419,15 +380,11 @@
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'l')
@@ -466,9 +423,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -481,14 +436,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -507,15 +458,11 @@
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
free(buf);
return NULL;
@@ -578,9 +525,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -590,14 +535,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -615,15 +556,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -685,9 +622,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -700,14 +635,10 @@
pcp_write(pc, process_id, strlen(process_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
while (1)
{
@@ -727,15 +658,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -836,9 +763,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -848,14 +773,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
while (1) {
if (pcp_read(pc, &tos, 1))
@@ -874,15 +795,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -1166,9 +1083,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1181,14 +1096,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1206,15 +1117,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'd')
@@ -1249,9 +1156,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1264,14 +1169,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1289,15 +1190,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1334,9 +1231,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1349,14 +1244,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1374,15 +1265,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1398,3 +1285,15 @@
free(buf);
return -1;
}
+
+void
+pcp_enable_debug(void)
+{
+ debug = 1;
+}
+
+void
+pcp_disable_debug(void)
+{
+ debug = 0;
+}

View File

@ -0,0 +1,16 @@
Index: pcp/pcp.h
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.h,v
retrieving revision 1.3
diff -u -r1.3 pcp.h
--- pcp/pcp.h 29 Jan 2008 01:56:37 -0000 1.3
+++ pcp/pcp.h 29 Dec 2008 05:15:44 -0000
@@ -62,6 +62,8 @@
extern int pcp_attach_node(int nid);
extern void pcp_set_timeout(long sec);
extern int pcp_recovery_node(int nid);
+extern void pcp_enable_debug(void);
+extern void pcp_disable_debug(void);
/* ------------------------------
* pcp_error.c

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_attach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_attach_node.c
--- pcp/pcp_attach_node.c 29 Jan 2008 01:56:37 -0000 1.2
+++ pcp/pcp_attach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_attach_node - attach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_attach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_attach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_attach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_detach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_detach_node.c
--- pcp/pcp_detach_node.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_detach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_detach_node - detach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_detach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_detach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_detach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,104 @@
Index: pcp/pcp_node_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_count.c
--- pcp/pcp_node_count.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,53 +39,64 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int node_count;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);
@@ -112,8 +124,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_count - display the total number of nodes under pgpool-II's control\n\n");
- fprintf(stderr, "Usage: pcp_node_count timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_node_count [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_node_count -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_node_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_info.c
--- pcp/pcp_node_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
BackendInfo *backend_info;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,23 +88,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -132,8 +144,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_info - display a pgpool-II node's information\n\n");
- fprintf(stderr, "Usage: pcp_node_info timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_node_info [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_node_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,93 @@
Index: pcp/pcp_proc_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_proc_count.c
--- pcp/pcp_proc_count.c 29 Jan 2008 01:56:38 -0000 1.3
+++ pcp/pcp_proc_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,53 +40,64 @@
char pass[MAX_USER_PASSWD_LEN];
int process_count;
int *process_list = NULL;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_proc_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_proc_info.c
--- pcp/pcp_proc_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_proc_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -40,36 +41,47 @@
int processID;
ProcessInfo *process_info;
int array_size;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -77,23 +89,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- processID = atoi(argv[6]);
+ processID = atoi(argv[5]);
if (processID < 0)
{
errorcode = INVALERR;
@@ -142,8 +154,9 @@
usage(void)
{
fprintf(stderr, "pcp_proc_info - display a pgpool-II child process' information\n\n");
- fprintf(stderr, "Usage: pcp_proc_info timeout hostname port# username password PID\n");
+ fprintf(stderr, "Usage: pcp_proc_info [-d] timeout hostname port# username password PID\n");
fprintf(stderr, "Usage: pcp_proc_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,120 @@
Index: pcp/pcp_recovery_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_recovery_node.c
--- pcp/pcp_recovery_node.c 12 Mar 2008 04:53:51 -0000 1.3
+++ pcp/pcp_recovery_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,30 +87,30 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
-
+
pcp_set_timeout(timeout);
if (pcp_connect(host, port, user, pass))
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_recovery_node - recovery a node\n\n");
- fprintf(stderr, "Usage: pcp_recovery_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_recovery_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,119 @@
Index: pcp/pcp_stop_pgpool.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_stop_pgpool.c
--- pcp/pcp_stop_pgpool.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_stop_pgpool.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
char mode;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,29 +87,29 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- if (strlen(argv[6]) != 1)
+ if (strlen(argv[5]) != 1)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- mode = argv[6][0];
+ mode = argv[5][0];
if (mode != 's' && mode != 'f' && mode != 'i')
{
errorcode = INVALERR;
@@ -131,8 +143,9 @@
usage(void)
{
fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_stop_pgpool timeout hostname port# username password mode\n");
+ fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n");
fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,109 @@
Index: pcp/pcp_systemdb_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_systemdb_info.c
--- pcp/pcp_systemdb_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_systemdb_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
SystemDBInfo *systemdb_info;
int i, j;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6)
+ if (argc != 5)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,21 +88,21 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
if (pcp_connect(host, port, user, pass))
{
@@ -146,8 +158,9 @@
usage(void)
{
fprintf(stderr, "pcp_systemdb_info - display the pgpool-II systemDB information\n\n");
- fprintf(stderr, "Usage: pcp_systemdb_info timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_systemdb_info [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_systemdb_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,16 @@
Index: pool_sema.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_sema.c,v
retrieving revision 1.4
diff -u -r1.4 pool_sema.c
--- pool_sema.c 29 Jan 2008 01:56:36 -0000 1.4
+++ pool_sema.c 29 Dec 2008 05:15:44 -0000
@@ -82,7 +82,7 @@
if (semId < 0)
{
- pool_error("could not create semaphores: %s", strerror(errno));
+ pool_error("could not create %d semaphores: %s", numSems, strerror(errno));
return -1;
}

View File

@ -21,9 +21,13 @@ lib/libpcp.so
lib/libpcp.so.0
%%DATADIR%%/dist_def_pgbench.sql
%%DATADIR%%/pgpool.pam
%%DATADIR%%/replicate_def_pgbench.sql
%%DATADIR%%/system_db.sql
%%EXAMPLESDIR%%/pgpool_recovery
%%EXAMPLESDIR%%/pgpool_recovery_pitr
%%EXAMPLESDIR%%/pgpool_remote_start
share/postgresql/contrib/pgpool-recovery.sql
lib/postgresql/pgpool-recovery.so
@dirrmtry share/postgresql/contrib
@dirrm %%EXAMPLESDIR%%
@dirrm %%DATADIR%%

View File

@ -6,10 +6,9 @@
#
PORTNAME= pgpool-II
PORTVERSION= 2.0.1
PORTREVISION= 2
PORTVERSION= 2.1
CATEGORIES= databases
MASTER_SITES= http://pgfoundry.org/frs/download.php/1521/
MASTER_SITES= http://pgfoundry.org/frs/download.php/1843/
MAINTAINER= kuriyama@FreeBSD.org
COMMENT= A connection pool server for PostgreSQL
@ -31,12 +30,19 @@ MAN8= pgpool.8
post-patch:
@${REINPLACE_CMD} -e 's|echo aout|echo elf|g' \
${WRKSRC}/configure
@${REINPLACE_CMD} -e 's| pg_config| ${LOCALBASE}/bin/pg_config|g' \
${WRKSRC}/sql/pgpool-recovery/Makefile
post-build:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE}
pre-install:
${MKDIR} ${DATADIR} ${EXAMPLESDIR}
post-install:
@cd ${WRKSRC}/sql/pgpool-recovery && ${GMAKE} install
${INSTALL_DATA} ${WRKSRC}/sample/dist_def_pgbench.sql ${DATADIR}
${INSTALL_DATA} ${WRKSRC}/sample/replicate_def_pgbench.sql ${DATADIR}
.for f in pgpool_recovery pgpool_recovery_pitr pgpool_remote_start
${INSTALL_SCRIPT} ${WRKSRC}/sample/${f} ${EXAMPLESDIR}
.endfor

View File

@ -1,3 +1,3 @@
MD5 (pgpool-II-2.0.1.tar.gz) = fdfd023b1400ae85455e8274bf0cb502
SHA256 (pgpool-II-2.0.1.tar.gz) = f30ca8ec9ec30a277dbffb06a9d11510e22e24fb457267c568ed46b046708961
SIZE (pgpool-II-2.0.1.tar.gz) = 913792
MD5 (pgpool-II-2.1.tar.gz) = cf02f9358f46849bd526798868e13162
SHA256 (pgpool-II-2.1.tar.gz) = 8834b6ca01eab57d2c947c1016f164e0538e45242f1d3a3fa99932dae87ba890
SIZE (pgpool-II-2.1.tar.gz) = 932731

View File

@ -1,53 +0,0 @@
--- main.c.orig 2007-11-09 13:37:35.000000000 +0900
+++ main.c 2008-03-03 10:24:27.651654702 +0900
@@ -836,7 +836,13 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ char *host = "", *serv = "";
+ char hostname[NI_MAXHOST], servname[NI_MAXSERV];
+ if (getnameinfo(&addr, len, hostname, sizeof(hostname), servname, sizeof(servname), 0) == 0) {
+ host = hostname;
+ serv = servname;
+ }
+ pool_error("bind(%s:%s) failed. reason: %s", host, serv, strerror(errno));
myexit(1);
}
@@ -872,7 +878,7 @@
status = bind(fd, (struct sockaddr *)&addr, len);
if (status == -1)
{
- pool_error("bind() failed. reason: %s", strerror(errno));
+ pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno));
myexit(1);
}
@@ -891,6 +897,12 @@
return fd;
}
+static void myunlink(const char* path)
+{
+ if (unlink(path) == 0) return;
+ pool_error("unlink(%s) failed: %s", path, strerror(errno));
+}
+
static void myexit(int code)
{
char path[POOLMAXPATHLEN];
@@ -917,10 +929,10 @@
POOL_SETMASK(&UnBlockSig);
}
- unlink(un_addr.sun_path);
- unlink(pcp_un_addr.sun_path);
+ myunlink(un_addr.sun_path);
+ myunlink(pcp_un_addr.sun_path);
snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
- unlink(path);
+ myunlink(path);
pool_shmem_exit(code);
exit(code);

View File

@ -0,0 +1,598 @@
Index: pcp/pcp.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.c,v
retrieving revision 1.7
diff -u -r1.7 pcp.c
--- pcp/pcp.c 8 Feb 2008 08:10:43 -0000 1.7
+++ pcp/pcp.c 29 Dec 2008 05:15:44 -0000
@@ -42,6 +42,11 @@
struct timeval pcp_timeout;
static PCP_CONNECTION *pc;
+#ifdef DEBUG
+static int debug = 1;
+#else
+static int debug = 0;
+#endif
static int pcp_authorize(char *username, char *password);
/* --------------------------------
@@ -62,9 +67,7 @@
if (pc != NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection to backend \"%s\" already exists\n", hostname);
return 0;
}
@@ -76,9 +79,7 @@
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -100,9 +101,7 @@
if (connect(fd, (struct sockaddr *) &unix_addr, sizeof(unix_addr)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", unix_addr.sun_path);
close(fd);
errorcode = CONNERR;
return -1;
@@ -113,9 +112,7 @@
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not create socket\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not create socket\n");
errorcode = SOCKERR;
return -1;
}
@@ -123,9 +120,7 @@
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &on, sizeof(on)) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not set socket option\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not set socket option\n");
close(fd);
errorcode = SOCKERR;
return -1;
@@ -136,9 +131,7 @@
hp = gethostbyname(hostname);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not retrieve hostname\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not retrieve hostname\n");
close(fd);
errorcode = HOSTERR;
return -1;
@@ -151,9 +144,7 @@
len = sizeof(struct sockaddr_in);
if (connect(fd, (struct sockaddr *) &addr, len) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not connect to \"%s\"\n", hostname);
close(fd);
errorcode = CONNERR;
return -1;
@@ -163,9 +154,7 @@
pc = pcp_open(fd);
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not allocate buffer space\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not allocate buffer space\n");
close(fd);
return -1;
}
@@ -202,9 +191,7 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
@@ -243,14 +230,10 @@
pcp_write(pc, encrypt_buf, strlen(encrypt_buf)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"R\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -265,15 +248,11 @@
}
if (pcp_read(pc, buf, rsize - sizeof(int)))
return -1;
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'r')
@@ -284,9 +263,7 @@
return 0;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: authentication failed. reason=%s\n", buf);
errorcode = AUTHERR;
}
free(buf);
@@ -305,9 +282,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
return;
}
@@ -318,9 +293,7 @@
{
/* backend had closed connection already */
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"X\", len=%d\n", sizeof(int));
pcp_close(pc);
pc = NULL;
@@ -339,9 +312,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -352,14 +323,10 @@
pcp_write(pc, &mode, sizeof(char));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"T\", len=%d\n", ntohl(wsize));
return 0;
}
@@ -381,9 +348,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -393,14 +358,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"L\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -419,15 +380,11 @@
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'l')
@@ -466,9 +423,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -481,14 +436,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"I\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -507,15 +458,11 @@
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
free(buf);
return NULL;
@@ -578,9 +525,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -590,14 +535,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"N\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return NULL;
@@ -615,15 +556,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -685,9 +622,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -700,14 +635,10 @@
pcp_write(pc, process_id, strlen(process_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"P\", len=%d\n", ntohl(wsize));
while (1)
{
@@ -727,15 +658,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -836,9 +763,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return NULL;
}
@@ -848,14 +773,10 @@
pcp_write(pc, &wsize, sizeof(int));
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"S\", len=%d\n", ntohl(wsize));
while (1) {
if (pcp_read(pc, &tos, 1))
@@ -874,15 +795,11 @@
free(buf);
return NULL;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
free(buf);
errorcode = BACKENDERR;
return NULL;
@@ -1166,9 +1083,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1181,14 +1096,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1206,15 +1117,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'd')
@@ -1249,9 +1156,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1264,14 +1169,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1289,15 +1190,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1334,9 +1231,7 @@
if (pc == NULL)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: connection does not exist\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: connection does not exist\n");
errorcode = NOCONNERR;
return -1;
}
@@ -1349,14 +1244,10 @@
pcp_write(pc, node_id, strlen(node_id)+1);
if (pcp_flush(pc) < 0)
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: could not send data to backend\n");
-#endif
+ if (debug) fprintf(stderr, "DEBUG: could not send data to backend\n");
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
-#endif
+ if (debug) fprintf(stderr, "DEBUG: send: tos=\"D\", len=%d\n", ntohl(wsize));
if (pcp_read(pc, &tos, 1))
return -1;
@@ -1374,15 +1265,11 @@
free(buf);
return -1;
}
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: recv: tos=\"%c\", len=%d, data=%s\n", tos, rsize, buf);
if (tos == 'e')
{
-#ifdef DEBUG
- fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
-#endif
+ if (debug) fprintf(stderr, "DEBUG: command failed. reason=%s\n", buf);
errorcode = BACKENDERR;
}
else if (tos == 'c')
@@ -1398,3 +1285,15 @@
free(buf);
return -1;
}
+
+void
+pcp_enable_debug(void)
+{
+ debug = 1;
+}
+
+void
+pcp_disable_debug(void)
+{
+ debug = 0;
+}

View File

@ -0,0 +1,16 @@
Index: pcp/pcp.h
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp.h,v
retrieving revision 1.3
diff -u -r1.3 pcp.h
--- pcp/pcp.h 29 Jan 2008 01:56:37 -0000 1.3
+++ pcp/pcp.h 29 Dec 2008 05:15:44 -0000
@@ -62,6 +62,8 @@
extern int pcp_attach_node(int nid);
extern void pcp_set_timeout(long sec);
extern int pcp_recovery_node(int nid);
+extern void pcp_enable_debug(void);
+extern void pcp_disable_debug(void);
/* ------------------------------
* pcp_error.c

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_attach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_attach_node.c
--- pcp/pcp_attach_node.c 29 Jan 2008 01:56:37 -0000 1.2
+++ pcp/pcp_attach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_attach_node - attach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_attach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_attach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_attach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_detach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_detach_node.c
--- pcp/pcp_detach_node.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_detach_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,23 +87,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_detach_node - detach a node from pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_detach_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_detach_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_detach_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,104 @@
Index: pcp/pcp_node_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_count.c
--- pcp/pcp_node_count.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,53 +39,64 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int node_count;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);
@@ -112,8 +124,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_count - display the total number of nodes under pgpool-II's control\n\n");
- fprintf(stderr, "Usage: pcp_node_count timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_node_count [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_node_count -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_node_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_node_info.c
--- pcp/pcp_node_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_node_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
BackendInfo *backend_info;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,23 +88,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
@@ -132,8 +144,9 @@
usage(void)
{
fprintf(stderr, "pcp_node_info - display a pgpool-II node's information\n\n");
- fprintf(stderr, "Usage: pcp_node_info timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_node_info [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_node_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,93 @@
Index: pcp/pcp_proc_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_proc_count.c
--- pcp/pcp_proc_count.c 29 Jan 2008 01:56:38 -0000 1.3
+++ pcp/pcp_proc_count.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,53 +40,64 @@
char pass[MAX_USER_PASSWD_LEN];
int process_count;
int *process_list = NULL;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6) {
+ if (argc != 5) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN) {
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN) {
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
pcp_set_timeout(timeout);

View File

@ -0,0 +1,112 @@
Index: pcp/pcp_proc_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_proc_info.c
--- pcp/pcp_proc_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_proc_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -40,36 +41,47 @@
int processID;
ProcessInfo *process_info;
int array_size;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -77,23 +89,23 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- processID = atoi(argv[6]);
+ processID = atoi(argv[5]);
if (processID < 0)
{
errorcode = INVALERR;
@@ -142,8 +154,9 @@
usage(void)
{
fprintf(stderr, "pcp_proc_info - display a pgpool-II child process' information\n\n");
- fprintf(stderr, "Usage: pcp_proc_info timeout hostname port# username password PID\n");
+ fprintf(stderr, "Usage: pcp_proc_info [-d] timeout hostname port# username password PID\n");
fprintf(stderr, "Usage: pcp_proc_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,120 @@
Index: pcp/pcp_recovery_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v
retrieving revision 1.3
diff -u -r1.3 pcp_recovery_node.c
--- pcp/pcp_recovery_node.c 12 Mar 2008 04:53:51 -0000 1.3
+++ pcp/pcp_recovery_node.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,30 +87,30 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- nodeID = atoi(argv[6]);
+ nodeID = atoi(argv[5]);
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
-
+
pcp_set_timeout(timeout);
if (pcp_connect(host, port, user, pass))
@@ -123,8 +135,9 @@
usage(void)
{
fprintf(stderr, "pcp_recovery_node - recovery a node\n\n");
- fprintf(stderr, "Usage: pcp_recovery_node timeout hostname port# username password nodeID\n");
+ fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n");
fprintf(stderr, "Usage: pcp_recovery_node -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,119 @@
Index: pcp/pcp_stop_pgpool.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_stop_pgpool.c
--- pcp/pcp_stop_pgpool.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_stop_pgpool.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -38,36 +39,47 @@
char user[MAX_USER_PASSWD_LEN];
char pass[MAX_USER_PASSWD_LEN];
char mode;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 7)
+ if (argc != 6)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -75,29 +87,29 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
- if (strlen(argv[6]) != 1)
+ if (strlen(argv[5]) != 1)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- mode = argv[6][0];
+ mode = argv[5][0];
if (mode != 's' && mode != 'f' && mode != 'i')
{
errorcode = INVALERR;
@@ -131,8 +143,9 @@
usage(void)
{
fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n");
- fprintf(stderr, "Usage: pcp_stop_pgpool timeout hostname port# username password mode\n");
+ fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n");
fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,109 @@
Index: pcp/pcp_systemdb_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v
retrieving revision 1.2
diff -u -r1.2 pcp_systemdb_info.c
--- pcp/pcp_systemdb_info.c 29 Jan 2008 01:56:38 -0000 1.2
+++ pcp/pcp_systemdb_info.c 29 Dec 2008 05:15:44 -0000
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pcp.h"
@@ -39,36 +40,47 @@
char pass[MAX_USER_PASSWD_LEN];
SystemDBInfo *systemdb_info;
int i, j;
+ int ch;
- if (argc == 2 && (strcmp(argv[1], "-h") == 0) )
- {
- usage();
- exit(0);
+ while ((ch = getopt(argc, argv, "hd")) != -1) {
+ switch (ch) {
+ case 'd':
+ pcp_enable_debug();
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage();
+ exit(0);
+ }
}
+ argc -= optind;
+ argv += optind;
- if (argc != 6)
+ if (argc != 5)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- timeout = atol(argv[1]);
+ timeout = atol(argv[0]);
if (timeout < 0) {
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- if (strlen(argv[2]) >= MAX_DB_HOST_NAMELEN)
+ if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(host, argv[2]);
+ strcpy(host, argv[1]);
- port = atoi(argv[3]);
+ port = atoi(argv[2]);
if (port <= 1024 || port > 65535)
{
errorcode = INVALERR;
@@ -76,21 +88,21 @@
myexit(errorcode);
}
- if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(user, argv[4]);
+ strcpy(user, argv[3]);
- if (strlen(argv[5]) >= MAX_USER_PASSWD_LEN)
+ if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
{
errorcode = INVALERR;
pcp_errorstr(errorcode);
myexit(errorcode);
}
- strcpy(pass, argv[5]);
+ strcpy(pass, argv[4]);
if (pcp_connect(host, port, user, pass))
{
@@ -146,8 +158,9 @@
usage(void)
{
fprintf(stderr, "pcp_systemdb_info - display the pgpool-II systemDB information\n\n");
- fprintf(stderr, "Usage: pcp_systemdb_info timeout hostname port# username password\n");
+ fprintf(stderr, "Usage: pcp_systemdb_info [-d] timeout hostname port# username password\n");
fprintf(stderr, "Usage: pcp_systemdb_info -h\n\n");
+ fprintf(stderr, " -d - enable debug message (optional)\n");
fprintf(stderr, " timeout - connection timeout value in seconds. command exits on timeout\n");
fprintf(stderr, " hostname - pgpool-II hostname\n");
fprintf(stderr, " port# - pgpool-II port number\n");

View File

@ -0,0 +1,16 @@
Index: pool_sema.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_sema.c,v
retrieving revision 1.4
diff -u -r1.4 pool_sema.c
--- pool_sema.c 29 Jan 2008 01:56:36 -0000 1.4
+++ pool_sema.c 29 Dec 2008 05:15:44 -0000
@@ -82,7 +82,7 @@
if (semId < 0)
{
- pool_error("could not create semaphores: %s", strerror(errno));
+ pool_error("could not create %d semaphores: %s", numSems, strerror(errno));
return -1;
}

View File

@ -21,9 +21,13 @@ lib/libpcp.so
lib/libpcp.so.0
%%DATADIR%%/dist_def_pgbench.sql
%%DATADIR%%/pgpool.pam
%%DATADIR%%/replicate_def_pgbench.sql
%%DATADIR%%/system_db.sql
%%EXAMPLESDIR%%/pgpool_recovery
%%EXAMPLESDIR%%/pgpool_recovery_pitr
%%EXAMPLESDIR%%/pgpool_remote_start
share/postgresql/contrib/pgpool-recovery.sql
lib/postgresql/pgpool-recovery.so
@dirrmtry share/postgresql/contrib
@dirrm %%EXAMPLESDIR%%
@dirrm %%DATADIR%%