From: Timo Sirainen Date: Fri, 14 Dec 2012 09:17:19 +0000 (+0200) Subject: dsync: Fixed hangs with remote dsyncing X-Git-Tag: 2.2.beta1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e65600bfe1995ddb88fd56cc7fa8791f658c25bd;p=thirdparty%2Fdovecot%2Fcore.git dsync: Fixed hangs with remote dsyncing --- diff --git a/src/doveadm/dsync/dsync-ibc-stream.c b/src/doveadm/dsync/dsync-ibc-stream.c index e8c9960a81..3fe7550e19 100644 --- a/src/doveadm/dsync/dsync-ibc-stream.c +++ b/src/doveadm/dsync/dsync-ibc-stream.c @@ -143,7 +143,11 @@ static void dsync_ibc_stream_stop(struct dsync_ibc_stream *ibc) static int dsync_ibc_stream_read_mail_stream(struct dsync_ibc_stream *ibc) { - if (i_stream_read(ibc->mail_input) < 0) { + while (i_stream_read(ibc->mail_input) > 0) { + i_stream_skip(ibc->mail_input, + i_stream_get_data_size(ibc->mail_input)); + } + if (ibc->mail_input->eof) { if (ibc->mail_input->stream_errno != 0) { errno = ibc->mail_input->stream_errno; i_error("dsync(%s): read() failed: %m", ibc->name); @@ -153,10 +157,10 @@ static int dsync_ibc_stream_read_mail_stream(struct dsync_ibc_stream *ibc) /* finished reading the mail stream */ i_assert(ibc->mail_input->eof); i_stream_seek(ibc->mail_input, 0); + ibc->has_pending_data = TRUE; ibc->mail_input = NULL; return 1; } - i_stream_skip(ibc->mail_input, i_stream_get_data_size(ibc->mail_input)); return 0; }