dovecot-2.2: dsync: Close mail streams earlier on failures to av...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 10 12:12:59 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/40dd9a080b6e
changeset: 15632:40dd9a080b6e
user: Timo Sirainen <tss at iki.fi>
date: Thu Jan 10 12:12:50 2013 +0200
description:
dsync: Close mail streams earlier on failures to avoid assert-crashing
diffstat:
src/doveadm/dsync/dsync-brain.c | 1 +
src/doveadm/dsync/dsync-ibc-pipe.c | 21 +++++++++++++++++++++
src/doveadm/dsync/dsync-ibc-private.h | 1 +
src/doveadm/dsync/dsync-ibc-stream.c | 11 +++++++++++
src/doveadm/dsync/dsync-ibc.c | 5 +++++
src/doveadm/dsync/dsync-ibc.h | 4 ++++
6 files changed, 43 insertions(+), 0 deletions(-)
diffs (117 lines):
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-brain.c Thu Jan 10 12:12:50 2013 +0200
@@ -158,6 +158,7 @@
if (dsync_ibc_has_failed(brain->ibc) ||
brain->state != DSYNC_STATE_DONE)
brain->failed = TRUE;
+ dsync_ibc_close_mail_streams(brain->ibc);
if (brain->box != NULL)
dsync_brain_sync_mailbox_deinit(brain);
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-ibc-pipe.c
--- a/src/doveadm/dsync/dsync-ibc-pipe.c Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-pipe.c Thu Jan 10 12:12:50 2013 +0200
@@ -434,6 +434,26 @@
return DSYNC_IBC_RECV_RET_OK;
}
+static void pipe_close_mail_streams(struct dsync_ibc_pipe *pipe)
+{
+ struct item *item;
+
+ if (array_count(&pipe->item_queue) > 0) {
+ item = array_idx_modifiable(&pipe->item_queue, 0);
+ if (item->type == ITEM_MAIL &&
+ item->u.mail.input != NULL)
+ i_stream_unref(&item->u.mail.input);
+ }
+}
+
+static void dsync_ibc_pipe_close_mail_streams(struct dsync_ibc *ibc)
+{
+ struct dsync_ibc_pipe *pipe = (struct dsync_ibc_pipe *)ibc;
+
+ pipe_close_mail_streams(pipe);
+ pipe_close_mail_streams(pipe->remote);
+}
+
static const struct dsync_ibc_vfuncs dsync_ibc_pipe_vfuncs = {
dsync_ibc_pipe_deinit,
dsync_ibc_pipe_send_handshake,
@@ -453,6 +473,7 @@
dsync_ibc_pipe_recv_mail_request,
dsync_ibc_pipe_send_mail,
dsync_ibc_pipe_recv_mail,
+ dsync_ibc_pipe_close_mail_streams,
dsync_ibc_pipe_is_send_queue_full,
dsync_ibc_pipe_has_pending_data
};
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-ibc-private.h
--- a/src/doveadm/dsync/dsync-ibc-private.h Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-private.h Thu Jan 10 12:12:50 2013 +0200
@@ -61,6 +61,7 @@
(*recv_mail)(struct dsync_ibc *ibc,
struct dsync_mail **mail_r);
+ void (*close_mail_streams)(struct dsync_ibc *ibc);
bool (*is_send_queue_full)(struct dsync_ibc *ibc);
bool (*has_pending_data)(struct dsync_ibc *ibc);
};
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-ibc-stream.c
--- a/src/doveadm/dsync/dsync-ibc-stream.c Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc-stream.c Thu Jan 10 12:12:50 2013 +0200
@@ -1489,6 +1489,16 @@
return DSYNC_IBC_RECV_RET_OK;
}
+static void dsync_ibc_stream_close_mail_streams(struct dsync_ibc *_ibc)
+{
+ struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc;
+
+ if (ibc->mail_output != NULL) {
+ i_stream_unref(&ibc->mail_output);
+ dsync_ibc_stream_stop(ibc);
+ }
+}
+
static bool dsync_ibc_stream_is_send_queue_full(struct dsync_ibc *_ibc)
{
struct dsync_ibc_stream *ibc = (struct dsync_ibc_stream *)_ibc;
@@ -1531,6 +1541,7 @@
dsync_ibc_stream_recv_mail_request,
dsync_ibc_stream_send_mail,
dsync_ibc_stream_recv_mail,
+ dsync_ibc_stream_close_mail_streams,
dsync_ibc_stream_is_send_queue_full,
dsync_ibc_stream_has_pending_data
};
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-ibc.c
--- a/src/doveadm/dsync/dsync-ibc.c Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc.c Thu Jan 10 12:12:50 2013 +0200
@@ -178,6 +178,11 @@
return ibc->v.recv_mail(ibc, mail_r);
}
+void dsync_ibc_close_mail_streams(struct dsync_ibc *ibc)
+{
+ ibc->v.close_mail_streams(ibc);
+}
+
bool dsync_ibc_has_failed(struct dsync_ibc *ibc)
{
return ibc->failed;
diff -r 577c6dd315c3 -r 40dd9a080b6e src/doveadm/dsync/dsync-ibc.h
--- a/src/doveadm/dsync/dsync-ibc.h Thu Jan 10 11:52:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-ibc.h Thu Jan 10 12:12:50 2013 +0200
@@ -110,6 +110,10 @@
enum dsync_ibc_recv_ret
dsync_ibc_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r);
+/* Close any mail input streams that are kept open. This needs to be called
+ before the mail is attempted to be freed (usually on error conditions). */
+void dsync_ibc_close_mail_streams(struct dsync_ibc *ibc);
+
bool dsync_ibc_has_failed(struct dsync_ibc *ibc);
bool dsync_ibc_is_send_queue_full(struct dsync_ibc *ibc);
bool dsync_ibc_has_pending_data(struct dsync_ibc *ibc);
More information about the dovecot-cvs
mailing list