pgpool2.git / summary / log / commit / refs

commit    80ddec29397f38467e6c0aaf23ec10decd6c3bea
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Date:     Fri Feb 20 05:27:41 2015 +0000

    Fix to use void * for receiving return value of thread function
    
    Previously int was used and this could occur stack buffer overflow.
    This caused an infinity loop of ping error at bringing up or down
    VIP, since a loop variable in a for loop was overwritten to zero.


src/watchdog/wd_ping.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/watchdog/wd_ping.c b/src/watchdog/wd_ping.c index db0ddcabc..dda6f6a65 100644 --- a/src/watchdog/wd_ping.c +++ b/src/watchdog/wd_ping.c @@ -106,14 +106,14 @@ wd_is_upper_ok(char * server_list) pthread_attr_destroy(&attr); for (i=0; i <cnt; ) { - int result; - rc = pthread_join(thread[i], (void **)&result); + void * result; + rc = pthread_join(thread[i], &result); if ((rc != 0) && (errno == EINTR)) { usleep(100); continue; } - if (result == WD_OK) + if (result == (void *)WD_OK) { rtn = WD_OK; } @@ -135,7 +135,7 @@ wd_is_unused_ip(char * ip) WdInfo thread_arg; int rtn = WD_NG; - int result; + void * result; if (ip == NULL) { @@ -152,12 +152,12 @@ wd_is_unused_ip(char * ip) rc = watchdog_thread_create(&thread, &attr, exec_ping, (void*)&thread_arg); pthread_attr_destroy(&attr); - rc = pthread_join(thread, (void **)&result); + rc = pthread_join(thread, &result); if ((rc != 0) && (errno == EINTR)) { return WD_NG; } - if (result == WD_NG) + if (result == (void *)WD_NG) { rtn = WD_OK; } [parent: e0750f4805fb]