sig_atomic_t signalFlags[MAX_INTERRUPTS];
} User1SignalSlot;
+#ifdef NOT_USED
/*
* Process pending signal actions.
*/
reload_config_request = 0; \
} \
} while (0)
+#endif
#define PGPOOLMAXLITSENQUEUELENGTH 10000
static void exec_child_restart(FAILOVER_CONTEXT *failover_context, int node_id);
static void exec_notice_pcp_child(FAILOVER_CONTEXT *failover_context);
+static void check_requests(void);
+#ifdef DEBUG
+static void print_signal_member(sigset_t *sig);
+#endif
+
static struct sockaddr_un un_addr; /* unix domain socket path */
static struct sockaddr_un pcp_un_addr; /* unix domain socket path for PCP */
ProcessInfo *process_info = NULL; /* Per child info table on shmem */
/* This is the main loop */
for (;;)
{
+ /* Check pending requests */
+ check_requests();
+#ifdef NOT_USED
CHECK_REQUEST;
-
+#endif
/*
* check for child signals to ensure child startup before reporting
* successful start.
int status;
int i;
- ereport(DEBUG1,
+ ereport(LOG,
(errmsg("reaper handler")));
if (exiting)
}
}
- ereport(DEBUG1,
+ ereport(LOG,
(errmsg("reaper handler: exiting normally")));
}
r = pool_pause(&timeout);
POOL_SETMASK(&BlockSig);
if (r > 0)
- CHECK_REQUEST;
+ check_requests();
POOL_SETMASK(&UnBlockSig);
gettimeofday(¤t_time, NULL);
}
return sockets;
}
+
+/*
+ * Check and execute pending requests set by signal interrupts.
+ */
+static
+void check_requests(void)
+{
+ /*
+ * Waking child request?
+ */
+ if (wakeup_request)
+ {
+ wakeup_children();
+ wakeup_request = 0;
+ }
+
+ /*
+ * Failover or failback request?
+ */
+ if (sigusr1_request)
+ {
+ do {
+ sigusr1_request = 0;
+ sigusr1_interrupt_processor();
+ } while (sigusr1_request == 1);
+ }
+
+ /*
+ * Unblock signals so that SIGQUIT/SIGTERRM/SIGINT can be accepted.
+ * They are all shutdown requests.
+ */
+ POOL_SETMASK(&UnBlockSig);
+
+ /*
+ * Reap child request?
+ */
+ if (sigchld_request)
+ {
+ reaper();
+ }
+
+ /*
+ * Configuration file reloading request?
+ */
+ if (reload_config_request)
+ {
+ reload_config();
+ reload_config_request = 0;
+ }
+
+ /*
+ * Block signals again
+ */
+ POOL_SETMASK(&BlockSig);
+}
+
+#ifdef DEBUG
+static
+void print_signal_member(sigset_t *sig)
+{
+ if (sigismember(sig, SIGQUIT))
+ ereport(LOG,
+ (errmsg("SIGQUIT is member")));
+ if (sigismember(sig, SIGINT))
+ ereport(LOG,
+ (errmsg("SIGINT is member")));
+ if (sigismember(sig, SIGTERM))
+ ereport(LOG,
+ (errmsg("SIGTERM is member")));
+}
+#endif