diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-16 23:12:24 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-16 23:12:24 +0000 |
commit | 78955d090e6121fb491259e15d5d6bee0237d460 (patch) | |
tree | b3a9df39e75eabd609b41e651429cc578ba94698 /src/plugins | |
parent | f7a94f785f581a43c3d48a605c5fe65a4d70d87f (diff) | |
download | rspamd-78955d090e6121fb491259e15d5d6bee0237d460.tar.gz rspamd-78955d090e6121fb491259e15d5d6bee0237d460.zip |
Check if we have some reply before retransmit
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/fuzzy_check.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index ea94021ed..c3e119475 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -1297,16 +1297,7 @@ fuzzy_check_io_callback (gint fd, short what, void *arg) task = session->task; - if (what == EV_WRITE) { - if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { - ret = return_error; - } - else { - session->state = 1; - ret = return_want_more; - } - } - else if (session->state == 1) { + if ((what & EV_READ) || session->state == 1) { /* Try to read reply */ if ((r = read (fd, buf, sizeof (buf) - 1)) == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { @@ -1385,6 +1376,15 @@ fuzzy_check_io_callback (gint fd, short what, void *arg) } } } + else if (what & EV_WRITE) { + if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { + ret = return_error; + } + else { + session->state = 1; + ret = return_want_more; + } + } else { /* Should not happen */ g_assert (0); @@ -1452,7 +1452,7 @@ fuzzy_check_timer_callback (gint fd, short what, void *arg) else { /* Plan write event */ event_del (&session->ev); - event_set (&session->ev, fd, EV_WRITE, + event_set (&session->ev, fd, EV_WRITE|EV_READ, fuzzy_check_io_callback, session); event_add (&session->ev, NULL); @@ -1484,18 +1484,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) task = session->task; - if (what == EV_WRITE) { - /* Send commands to storage */ - if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { - if (*(session->err) == NULL) { - g_set_error (session->err, - g_quark_from_static_string ("fuzzy check"), - errno, "write socket error: %s", strerror (errno)); - } - ret = return_error; - } - } - else if (what == EV_READ) { + if (what & EV_READ) { if ((r = read (fd, buf, sizeof (buf) - 1)) == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { event_add (&session->ev, NULL); @@ -1569,6 +1558,17 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) } } } + else if (what & EV_WRITE) { + /* Send commands to storage */ + if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { + if (*(session->err) == NULL) { + g_set_error (session->err, + g_quark_from_static_string ("fuzzy check"), + errno, "write socket error: %s", strerror (errno)); + } + ret = return_error; + } + } else { g_assert (0); } @@ -1663,7 +1663,7 @@ fuzzy_controller_timer_callback (gint fd, short what, void *arg) else { /* Plan write event */ event_del (&session->ev); - event_set (&session->ev, fd, EV_WRITE, + event_set (&session->ev, fd, EV_WRITE|EV_READ, fuzzy_controller_io_callback, session); event_add (&session->ev, NULL); |