Skip to content

Commit 02d3322

Browse files
committed
Use standard SIGHUP handler in syslogger.
Commit 1e53fe0 changed background processes so that they use standard SIGHUP handler. Like that, this commit makes syslogger use standard SIGHUP handler to simplify the code. Author: Bharath Rupireddy Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/CALj2ACXPorUqePswDtOeM_s82v9RW32E1fYmOPZ5NuE+TWKj_A@mail.gmail.com
1 parent 9f12a3b commit 02d3322

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/backend/postmaster/syslogger.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "pgstat.h"
4040
#include "pgtime.h"
4141
#include "postmaster/fork_process.h"
42+
#include "postmaster/interrupt.h"
4243
#include "postmaster/postmaster.h"
4344
#include "postmaster/syslogger.h"
4445
#include "storage/dsm.h"
@@ -123,7 +124,6 @@ static CRITICAL_SECTION sysloggerSection;
123124
/*
124125
* Flags set by interrupt handlers for later service in the main loop.
125126
*/
126-
static volatile sig_atomic_t got_SIGHUP = false;
127127
static volatile sig_atomic_t rotation_requested = false;
128128

129129

@@ -144,7 +144,6 @@ static unsigned int __stdcall pipeThread(void *arg);
144144
static void logfile_rotate(bool time_based_rotation, int size_rotation_for);
145145
static char *logfile_getname(pg_time_t timestamp, const char *suffix);
146146
static void set_next_rotation_time(void);
147-
static void sigHupHandler(SIGNAL_ARGS);
148147
static void sigUsr1Handler(SIGNAL_ARGS);
149148
static void update_metainfo_datafile(void);
150149

@@ -240,7 +239,7 @@ SysLoggerMain(int argc, char *argv[])
240239
* broken backends...
241240
*/
242241

243-
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
242+
pqsignal(SIGHUP, SignalHandlerForConfigReload); /* set flag to read config file */
244243
pqsignal(SIGINT, SIG_IGN);
245244
pqsignal(SIGTERM, SIG_IGN);
246245
pqsignal(SIGQUIT, SIG_IGN);
@@ -324,9 +323,9 @@ SysLoggerMain(int argc, char *argv[])
324323
/*
325324
* Process any requests or signals received recently.
326325
*/
327-
if (got_SIGHUP)
326+
if (ConfigReloadPending)
328327
{
329-
got_SIGHUP = false;
328+
ConfigReloadPending = false;
330329
ProcessConfigFile(PGC_SIGHUP);
331330

332331
/*
@@ -1553,18 +1552,6 @@ RemoveLogrotateSignalFiles(void)
15531552
unlink(LOGROTATE_SIGNAL_FILE);
15541553
}
15551554

1556-
/* SIGHUP: set flag to reload config file */
1557-
static void
1558-
sigHupHandler(SIGNAL_ARGS)
1559-
{
1560-
int save_errno = errno;
1561-
1562-
got_SIGHUP = true;
1563-
SetLatch(MyLatch);
1564-
1565-
errno = save_errno;
1566-
}
1567-
15681555
/* SIGUSR1: set flag to rotate logfile */
15691556
static void
15701557
sigUsr1Handler(SIGNAL_ARGS)

0 commit comments

Comments
 (0)