dovecot-2.0: lib-lda: Don't crash if remote disconnects during s...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Aug 23 20:43:55 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/2f988e370a41
changeset: 12879:2f988e370a41
user: Timo Sirainen <tss at iki.fi>
date: Tue Aug 23 20:43:36 2011 +0300
description:
lib-lda: Don't crash if remote disconnects during sending mail via LMTP.
diffstat:
src/lib-lda/lmtp-client.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (41 lines):
diff -r 1449a2e2c1f5 -r 2f988e370a41 src/lib-lda/lmtp-client.c
--- a/src/lib-lda/lmtp-client.c Thu Aug 18 18:21:33 2011 +0300
+++ b/src/lib-lda/lmtp-client.c Tue Aug 23 20:43:36 2011 +0300
@@ -101,9 +101,9 @@
if (client->io != NULL)
io_remove(&client->io);
if (client->input != NULL)
- i_stream_unref(&client->input);
+ i_stream_close(client->input);
if (client->output != NULL)
- o_stream_unref(&client->output);
+ o_stream_close(client->output);
if (client->fd != -1) {
net_disconnect(client->fd);
client->fd = -1;
@@ -120,7 +120,7 @@
static void lmtp_client_ref(struct lmtp_client *client)
{
- pool_ref(client->pool);
+ client->refcount++;
}
static void lmtp_client_unref(struct lmtp_client **_client)
@@ -128,6 +128,16 @@
struct lmtp_client *client = *_client;
*_client = NULL;
+
+ i_assert(client->refcount > 0);
+ if (--client->refcount > 0)
+ return;
+
+ i_assert(client->finish_called);
+ if (client->input != NULL)
+ i_stream_unref(&client->input);
+ if (client->output != NULL)
+ o_stream_unref(&client->output);
pool_unref(&client->pool);
}
More information about the dovecot-cvs
mailing list