From: Vsevolod Stakhov Date: Thu, 6 Jun 2013 16:31:31 +0000 (+0100) Subject: Update buffers logic for streaming read. X-Git-Tag: 0.5.6~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=55e35bf938fcdf95f59950bae2674f1606e306c3;p=rspamd.git Update buffers logic for streaming read. --- 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) {