Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d239c1a

Browse files
committed
postmaster: Don't open-code TerminateChildren() in HandleChildCrash()
After removing the duplication no user of sigquit_child() remains, therefore remove it. Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://postgr.es/m/kgng5nrvnlv335evmsuvpnh354rw7qyazl73kdysev2cr2v5zu@m3cfzxicm5kp
1 parent 4d271e3 commit d239c1a

File tree

1 file changed

+11
-38
lines changed

1 file changed

+11
-38
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ bool enable_bonjour = false;
243243
char *bonjour_name;
244244
bool restart_after_crash = true;
245245
bool remove_temp_files_after_crash = true;
246+
247+
/*
248+
* When terminating child processes after fatal errors, like a crash of a
249+
* child process, we normally send SIGQUIT -- and most other comments in this
250+
* file are written on the assumption that we do -- but developers might
251+
* prefer to use SIGABRT to collect per-child core dumps.
252+
*/
246253
bool send_abort_for_crash = false;
247254
bool send_abort_for_kill = false;
248255

@@ -424,7 +431,6 @@ static int BackendStartup(ClientSocket *client_sock);
424431
static void report_fork_failure_to_client(ClientSocket *client_sock, int errnum);
425432
static CAC_state canAcceptConnections(BackendType backend_type);
426433
static void signal_child(PMChild *pmchild, int signal);
427-
static void sigquit_child(PMChild *pmchild);
428434
static bool SignalChildren(int signal, BackendTypeMask targetMask);
429435
static void TerminateChildren(int signal);
430436
static int CountChildren(BackendTypeMask targetMask);
@@ -2701,32 +2707,12 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
27012707
/*
27022708
* Signal all other child processes to exit. The crashed process has
27032709
* already been removed from ActiveChildList.
2710+
*
2711+
* We could exclude dead-end children here, but at least when sending
2712+
* SIGABRT it seems better to include them.
27042713
*/
27052714
if (take_action)
2706-
{
2707-
dlist_iter iter;
2708-
2709-
dlist_foreach(iter, &ActiveChildList)
2710-
{
2711-
PMChild *bp = dlist_container(PMChild, elem, iter.cur);
2712-
2713-
/* We do NOT restart the syslogger */
2714-
if (bp == SysLoggerPMChild)
2715-
continue;
2716-
2717-
if (bp == StartupPMChild)
2718-
StartupStatus = STARTUP_SIGNALED;
2719-
2720-
/*
2721-
* This backend is still alive. Unless we did so already, tell it
2722-
* to commit hara-kiri.
2723-
*
2724-
* We could exclude dead-end children here, but at least when
2725-
* sending SIGABRT it seems better to include them.
2726-
*/
2727-
sigquit_child(bp);
2728-
}
2729-
}
2715+
TerminateChildren(send_abort_for_crash ? SIGABRT : SIGQUIT);
27302716

27312717
if (Shutdown != ImmediateShutdown)
27322718
FatalError = true;
@@ -3349,19 +3335,6 @@ signal_child(PMChild *pmchild, int signal)
33493335
#endif
33503336
}
33513337

3352-
/*
3353-
* Convenience function for killing a child process after a crash of some
3354-
* other child process. We apply send_abort_for_crash to decide which signal
3355-
* to send. Normally it's SIGQUIT -- and most other comments in this file are
3356-
* written on the assumption that it is -- but developers might prefer to use
3357-
* SIGABRT to collect per-child core dumps.
3358-
*/
3359-
static void
3360-
sigquit_child(PMChild *pmchild)
3361-
{
3362-
signal_child(pmchild, (send_abort_for_crash ? SIGABRT : SIGQUIT));
3363-
}
3364-
33653338
/*
33663339
* Send a signal to the targeted children.
33673340
*/

0 commit comments

Comments
 (0)