]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Remove events when 0 or error are returned
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jan 2016 23:51:24 +0000 (23:51 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jan 2016 23:51:24 +0000 (23:51 +0000)
src/libserver/rspamd_control.c

index 6f0bd8a4ddce1d2d96aceea3357f09850c9468d6..e274f100b26749a7c011f570dba1b79438d9ec39 100644 (file)
@@ -548,16 +548,25 @@ rspamd_control_default_worker_handler (gint fd, short what, gpointer ud)
 
        gssize r;
 
-
        r = read (fd, &cmd, sizeof (cmd));
 
        if (r == -1) {
                msg_err ("cannot read request from the control socket: %s",
                                strerror (errno));
+
+               if (errno != EAGAIN && errno != EINTR) {
+                       event_del (&cd->io_ev);
+                       close (fd);
+               }
        }
        else if (r < (gint)sizeof (cmd)) {
                msg_err ("short read of control command: %d of %d", (gint)r,
                                (gint)sizeof (cmd));
+
+               if (r == 0) {
+                       event_del (&cd->io_ev);
+                       close (fd);
+               }
        }
        else if ((gint)cmd.type >= 0 && cmd.type < RSPAMD_CONTROL_MAX) {