提交 862f5dbd 编写于 作者: H Heikki Linnakangas

Disable triggering failover with a signal in pg_standby on Windows, because

Windows doesn't do signal processing like other platforms do. It never
really worked, but recent changes to the signal handling made it crash.

This fixes bug #4961. Patch by Fujii Masao.
上级 92504858
...@@ -51,7 +51,9 @@ bool triggered = false; /* have we been triggered? */ ...@@ -51,7 +51,9 @@ bool triggered = false; /* have we been triggered? */
bool need_cleanup = false; /* do we need to remove files from bool need_cleanup = false; /* do we need to remove files from
* archive? */ * archive? */
#ifndef WIN32
static volatile sig_atomic_t signaled = false; static volatile sig_atomic_t signaled = false;
#endif
char *archiveLocation; /* where to find the archive? */ char *archiveLocation; /* where to find the archive? */
char *triggerPath; /* where to find the trigger file? */ char *triggerPath; /* where to find the trigger file? */
...@@ -445,13 +447,13 @@ usage(void) ...@@ -445,13 +447,13 @@ usage(void)
fflush(stderr); fflush(stderr);
} }
#ifndef WIN32
static void static void
sighandler(int sig) sighandler(int sig)
{ {
signaled = true; signaled = true;
} }
#ifndef WIN32
/* We don't want SIGQUIT to core dump */ /* We don't want SIGQUIT to core dump */
static void static void
sigquit_handler(int sig) sigquit_handler(int sig)
...@@ -467,6 +469,7 @@ main(int argc, char **argv) ...@@ -467,6 +469,7 @@ main(int argc, char **argv)
{ {
int c; int c;
#ifndef WIN32
/* /*
* You can send SIGUSR1 to trigger failover. * You can send SIGUSR1 to trigger failover.
* *
...@@ -478,10 +481,11 @@ main(int argc, char **argv) ...@@ -478,10 +481,11 @@ main(int argc, char **argv)
* turned out to be a bad idea because postmaster uses SIGQUIT to * turned out to be a bad idea because postmaster uses SIGQUIT to
* request immediate shutdown. We still trap SIGINT, but that may * request immediate shutdown. We still trap SIGINT, but that may
* change in a future release. * change in a future release.
*
* There's no way to trigger failover via signal on Windows.
*/ */
(void) signal(SIGUSR1, sighandler); (void) signal(SIGUSR1, sighandler);
(void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */ (void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
#ifndef WIN32
(void) signal(SIGQUIT, sigquit_handler); (void) signal(SIGQUIT, sigquit_handler);
#endif #endif
...@@ -657,6 +661,7 @@ main(int argc, char **argv) ...@@ -657,6 +661,7 @@ main(int argc, char **argv)
if (sleeptime <= 60) if (sleeptime <= 60)
pg_usleep(sleeptime * 1000000L); pg_usleep(sleeptime * 1000000L);
#ifndef WIN32
if (signaled) if (signaled)
{ {
triggered = true; triggered = true;
...@@ -667,6 +672,7 @@ main(int argc, char **argv) ...@@ -667,6 +672,7 @@ main(int argc, char **argv)
} }
} }
else else
#endif
{ {
if (debug) if (debug)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册