#include "version.h"
-#define CHECK_FAILOVER_REQUEST \
+#define CHECK_REQUEST \
do \
{ \
if (failover_request) \
failover(failover_request); \
failover_request = 0; \
} \
+ if (sigchld_request) \
+ { \
+ reaper(); \
+ sigchld_request = 0; \
+ } \
} while (0)
#define PGPOOLMAXLITSENQUEUELENGTH 10000
static int create_inet_domain_socket(const char *hostname);
static void myexit(int code);
static void failover(int sig);
+static void reaper(void);
static RETSIGTYPE exit_handler(int sig);
static RETSIGTYPE reap_handler(int sig);
static int health_check_timer_expired; /* non 0 if health check timer expired */
static volatile int failover_request = 0;
+static volatile int sigchld_request = 0;
int myargc;
char **myargv;
*/
for (;;)
{
- CHECK_FAILOVER_REQUEST;
+ CHECK_REQUEST;
/* do we need health checking for PostgreSQL? */
if (!degenerated && pool_config.health_check_period > 0)
while (sleep_time > 0)
{
sleep_time = sleep(sleep_time);
- CHECK_FAILOVER_REQUEST;
+ CHECK_REQUEST;
}
}
else
* handle SIGCHLD
*/
static RETSIGTYPE reap_handler(int sig)
+{
+ sigchld_request = 1;
+}
+
+
+static void reaper(void)
{
pid_t pid;
int status;