From 55e35bf938fcdf95f59950bae2674f1606e306c3 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 6 Jun 2013 17:31:31 +0100 Subject: [PATCH] Update buffers logic for streaming read. --- src/buffer.c | 11 +++++++++-- src/worker.c | 8 -------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index c81c6a686..5912f7040 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -523,9 +523,16 @@ read_buffers (gint fd, rspamd_io_dispatcher_t * d, gboolean skip_read) case BUFFER_ANY: res.begin = d->in_buf->data->begin; res.len = len; + if (d->read_callback) { - if (!d->read_callback (&res, d->user_data)) { - return; + /* + * Actually we do not want to send zero sized + * buffers to a read callback + */ + if (! (d->want_read && res.len == 0)) { + if (!d->read_callback (&res, d->user_data)) { + return; + } } if (d->policy != saved_policy) { debug_ip("policy changed during callback, restart buffer's processing"); diff --git a/src/worker.c b/src/worker.c index e00ec8d4d..54cb540d3 100644 --- a/src/worker.c +++ b/src/worker.c @@ -308,14 +308,6 @@ read_socket (f_str_t * in, void *arg) task->dispatcher->want_read = FALSE; } else { - if (task->dispatcher->want_read && in->len == 0) { - /* - * Skip initial zero length string remain from - * buffer policy switch - */ - task->dispatcher->want_read = FALSE; - return TRUE; - } task->dispatcher->want_read = FALSE; if (in->len > 0) { if (task->msg->begin == NULL) { -- 2.39.5