]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Slightly improve logging in case of termination
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Nov 2019 16:05:46 +0000 (16:05 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Nov 2019 16:05:46 +0000 (16:05 +0000)
src/libserver/rspamd_control.c
src/lua/lua_worker.c
src/rspamd.c

index 503825184e7523eaca562925fb6e5ed4c0d7d424..e119e64d42cfb8696d5c4bb8c59dc4322a2bf3e5 100644 (file)
@@ -655,10 +655,15 @@ rspamd_control_default_worker_handler (EV_P_ ev_io *w, int revents)
        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);
                }
index 940c6ae4add4ef08d336c5aae77ee2a22eb0a223..4a3e4e908c212804b98546516e2252e4c18c9a52 100644 (file)
@@ -841,7 +841,8 @@ lua_worker_spawn_process (lua_State *L)
                /* 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 {
index 4b33e75770b74190868c6d52de1a2d6b4f6f3d5c..4eed0205f060a64d2fb3ce80fd3581f30d0eea18 100644 (file)
@@ -1092,11 +1092,13 @@ rspamd_cld_handler (EV_P_ ev_child *w, struct rspamd_main *rspamd_main,
                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);