r = recvmsg (w->fd, &msg, 0);
if (r == -1) {
- msg_err ("cannot read request from the control socket: %s",
- strerror (errno));
-
if (errno != EAGAIN && errno != EINTR) {
+ if (errno != ECONNRESET) {
+ /*
+ * In case of connection reset it means that main process
+ * has died, so do not pollute logs
+ */
+ msg_err ("cannot read request from the control socket: %s",
+ strerror (errno));
+ }
ev_io_stop (cd->ev_base, &cd->io_ev);
close (w->fd);
}
/* Wait for parent to reply and exit */
rc = read (cbdata->sp[1], inbuf, sizeof (inbuf));
- if (memcmp (inbuf, "\0\0\0\0", 4) == 0) {
+ if (rc >= sizeof (inbuf) &&
+ memcmp (inbuf, "\0\0\0\0", sizeof (inbuf)) == 0) {
exit (EXIT_SUCCESS);
}
else {
close (wrk->srv_pipe[0]);
}
- cmd.type = RSPAMD_CONTROL_CHILD_CHANGE;
- cmd.cmd.child_change.what = rspamd_child_terminated;
- cmd.cmd.child_change.pid = wrk->pid;
- cmd.cmd.child_change.additional = w->rstatus;
- rspamd_control_broadcast_srv_cmd (rspamd_main, &cmd, wrk->pid);
+ if (!rspamd_main->wanna_die) {
+ cmd.type = RSPAMD_CONTROL_CHILD_CHANGE;
+ cmd.cmd.child_change.what = rspamd_child_terminated;
+ cmd.cmd.child_change.pid = wrk->pid;
+ cmd.cmd.child_change.additional = w->rstatus;
+ rspamd_control_broadcast_srv_cmd (rspamd_main, &cmd, wrk->pid);
+ }
if (wrk->finish_actions) {
g_ptr_array_free (wrk->finish_actions, TRUE);