diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-14 23:51:24 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-14 23:51:24 +0000 |
commit | d250e7c04ccafe9090d34298ede98c4a7511aba4 (patch) | |
tree | 989ec1ead9d16adf1f83a198083a3736b88325ae | |
parent | e8b103d9a1e681280077c53ee2f8830ef8905177 (diff) | |
download | rspamd-d250e7c04ccafe9090d34298ede98c4a7511aba4.tar.gz rspamd-d250e7c04ccafe9090d34298ede98c4a7511aba4.zip |
Remove events when 0 or error are returned
-rw-r--r-- | src/libserver/rspamd_control.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index 6f0bd8a4d..e274f100b 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -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) { |