pgpool2.git / summary / log / commit / refs
commit 58a039f93e372a168f2096d8ff976daed467d5e4
Author: Muhammad Usama <m.usama@gmail.com>
Date: Tue Nov 03 22:51:14 2015 +0000
Fixing the watchdog regression test case and a mistake done by previous commit
where wrong pfree a string in pool_config.l was causing a segmentation fault.
The commit also fix a problem in the watchdog code, For IPC result packets with
json data payload, the payload should also include the string terminator character
src/config/pool_config.c | 32 +++++++++++---------------
src/config/pool_config.l | 5 ----
src/test/regression/tests/004.watchdog/test.sh | 14 +++++------
src/watchdog/watchdog.c | 6 ++---
4 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/src/config/pool_config.c b/src/config/pool_config.c
index 28aad5fe1..c1448d09d 100644
--- a/src/config/pool_config.c
+++ b/src/config/pool_config.c
@@ -8,7 +8,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_SUBMINOR_VERSION 37
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -46,7 +46,6 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
-typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
@@ -54,7 +53,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@@ -85,6 +83,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@@ -332,7 +332,7 @@ void yyfree (void * );
/* Begin user sect3 */
-#define yywrap(n) 1
+#define yywrap() 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
@@ -358,7 +358,7 @@ static void yy_fatal_error (yyconst char msg[] );
*/
#define YY_DO_BEFORE_ACTION \
(yytext_ptr) = yy_bp; \
- yyleng = (yy_size_t) (yy_cp - yy_bp); \
+ yyleng = (size_t) (yy_cp - yy_bp); \
(yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
@@ -634,7 +634,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -645,7 +645,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- yy_size_t n; \
+ size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -1062,7 +1062,7 @@ static int yy_get_next_buffer (void)
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
@@ -1195,7 +1195,7 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 37);
- return yy_is_jam ? 0 : yy_current_state;
+ return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_INPUT
@@ -1246,7 +1246,7 @@ static int yy_get_next_buffer (void)
case EOB_ACT_END_OF_FILE:
{
if ( yywrap( ) )
- return 0;
+ return EOF;
if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
@@ -1586,8 +1586,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
@@ -1595,7 +1595,8 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
{
YY_BUFFER_STATE b;
char *buf;
- yy_size_t n, i;
+ yy_size_t n;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@@ -3595,7 +3596,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
if (context == INIT_CONFIG ||
(context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED))
strlcpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN);
- pfree(str);
}
@@ -3712,7 +3712,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
if (context == INIT_CONFIG ||
(context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))
strlcpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH);
- pfree(str);
}
else if (!strncmp(key, "backend_flag", 12) &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
@@ -3893,7 +3892,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_INFO(slot).hostname, str, WD_MAX_HOST_NAMELEN);
- pfree(str);
}
else if (!strncmp(key, "other_pgpool_port", 17) &&
@@ -4442,7 +4440,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
- pfree(str);
}
/* this must be prior to hertbeat_destination */
else if (!strncmp(key, "heartbeat_destination_port", 26) &&
@@ -4494,7 +4491,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_HB_IF(slot).addr, str, WD_MAX_HOST_NAMELEN);
- pfree(str);
}
else if (!strcmp(key, "ssl") && CHECK_CONTEXT(INIT_CONFIG, context))
diff --git a/src/config/pool_config.l b/src/config/pool_config.l
index 282d9c57b..78ee2aeaf 100644
--- a/src/config/pool_config.l
+++ b/src/config/pool_config.l
@@ -1870,7 +1870,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
if (context == INIT_CONFIG ||
(context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED))
strlcpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN);
- pfree(str);
}
@@ -1987,7 +1986,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
if (context == INIT_CONFIG ||
(context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))
strlcpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH);
- pfree(str);
}
else if (!strncmp(key, "backend_flag", 12) &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
@@ -2168,7 +2166,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_INFO(slot).hostname, str, WD_MAX_HOST_NAMELEN);
- pfree(str);
}
else if (!strncmp(key, "other_pgpool_port", 17) &&
@@ -2717,7 +2714,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
- pfree(str);
}
/* this must be prior to hertbeat_destination */
else if (!strncmp(key, "heartbeat_destination_port", 26) &&
@@ -2769,7 +2765,6 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
strlcpy(WD_HB_IF(slot).addr, str, WD_MAX_HOST_NAMELEN);
- pfree(str);
}
else if (!strcmp(key, "ssl") && CHECK_CONTEXT(INIT_CONFIG, context))
diff --git a/src/test/regression/tests/004.watchdog/test.sh b/src/test/regression/tests/004.watchdog/test.sh
index 3fb0c0057..f700bd6a4 100755
--- a/src/test/regression/tests/004.watchdog/test.sh
+++ b/src/test/regression/tests/004.watchdog/test.sh
@@ -30,13 +30,13 @@ cd ..
# create standby environment
cd $sdir
+mkdir log
echo -n "creating standby pgpool..."
-source ./bashrc.ports
cat ../standby.conf >> etc/pgpool.conf
# since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
echo "pid_file_name = '$PWD/pgpool2.pid'" >> etc/pgpool.conf
# start the stnadby pgpool-II by hand
-$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f etc/pgpool.conf -F etc/pcp.conf -a etc/pool_hba.conf > log/pgpool.log 2>&1 &
+$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f etc/pgpool.conf -F $PWD/etc/pcp.conf -a $PWD/etc/pool_hba.conf > $PWD/log/pgpool.log 2>&1 &
wait_for_pgpool_startup
cd ..
@@ -44,7 +44,7 @@ cd ..
echo "Waiting for the pgpool master..."
for i in 1 2 3 4 5 6 7 8 9 10
do
- RESULT=`grep "I am the cluster leader node. Starting escalation process" master/log/pgpool.log`
+ RESULT=`grep "I am the cluster leader node. Starting escalation process" $PWD/master/log/pgpool.log`
if [ ! -z "$RESULT" ]; then
success_count=$(( success_count + 1 ))
echo "Master brought up successfully."
@@ -58,7 +58,7 @@ done
echo "Waiting for the pgpool master..."
for i in 1 2 3 4 5 6 7 8 9 10
do
- RESULT=`grep "successfully joined the watchdog cluster as standby node" standby/log/pgpool.log`
+ RESULT=`grep "successfully joined the watchdog cluster as standby node" $PWD/standby/log/pgpool.log`
if [ ! -z "$RESULT" ]; then
success_count=$(( success_count + 1 ))
echo "Standby successfully connected."
@@ -74,7 +74,7 @@ $PGPOOL_INSTALL_DIR/bin/pgpool -f master/etc/pgpool.conf -m f stop
echo "Checking if the Standby pgpool-II detected the master shutdown..."
for i in 1 2 3 4 5 6 7 8 9 10
do
- RESULT=`grep " is shutting down" standby/log/pgpool.log`
+ RESULT=`grep " is shutting down" $PWD/standby/log/pgpool.log`
if [ ! -z "$RESULT" ]; then
success_count=$(( success_count + 1 ))
echo "Master shutdown detected."
@@ -90,7 +90,7 @@ $PGPOOL_INSTALL_DIR/bin/pgpool -f master/etc/pgpool.conf -m f stop
echo "Checking if the Standby pgpool-II takes over the master responsibility..."
for i in 1 2 3 4 5 6 7 8 9 10
do
- RESULT=`grep "I am the cluster leader node. Starting escalation process" standby/log/pgpool.log`
+ RESULT=`grep "I am the cluster leader node. Starting escalation process" $PWD/standby/log/pgpool.log`
if [ ! -z "$RESULT" ]; then
success_count=$(( success_count + 1 ))
echo "Standby successfully became the new master."
@@ -100,7 +100,7 @@ do
sleep 2
done
-$PGPOOL_INSTALL_DIR/bin/pgpool -f standby/etc/pgpool.conf -m f stop
+$PGPOOL_INSTALL_DIR/bin/pgpool -f $PWD/standby/etc/pgpool.conf -m f stop
cd master
./shutdownall
diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c
index fa4e5f53c..70aa34944 100644
--- a/src/watchdog/watchdog.c
+++ b/src/watchdog/watchdog.c
@@ -1505,7 +1505,7 @@ static IPC_CMD_PREOCESS_RES process_IPC_nodeList_command(WDIPCCommandData* IPCCo
json_value_free(root);
jNode = get_node_list_json(NodeID);
ret = write_ipc_command_with_result_data(IPCCommand, WD_IPC_CMD_RESULT_OK,
- jw_get_json_string(jNode), jw_get_json_length(jNode));
+ jw_get_json_string(jNode), jw_get_json_length(jNode) +1);
jw_destroy(jNode);
if (ret == false)
return IPC_CMD_ERROR;
@@ -1998,7 +1998,7 @@ static void process_failover_command_sync_requests(WatchdogNode* wdNode, WDPacke
}
else
{
- reply_with_message(wdNode, WD_DATA_MESSAGE, jw_get_json_string(jNode), jw_get_json_length(jNode), pkt);
+ reply_with_message(wdNode, WD_DATA_MESSAGE, jw_get_json_string(jNode), jw_get_json_length(jNode) + 1, pkt);
}
}
else
@@ -2008,7 +2008,7 @@ static void process_failover_command_sync_requests(WatchdogNode* wdNode, WDPacke
if (jNode != NULL)
{
ret = write_ipc_command_with_result_data(ipcCommand, WD_IPC_CMD_RESULT_OK,
- jw_get_json_string(jNode), jw_get_json_length(jNode));
+ jw_get_json_string(jNode), jw_get_json_length(jNode) +1);
jw_destroy(jNode);
}
else
[parent: 856a0bd21915]