dovecot-2.2-pigeonhole: Sieve extprograms plugin: Fixed fd leak ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Fri Dec 13 22:36:10 EET 2013
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/61772824b4ea
changeset: 1822:61772824b4ea
user: Stephan Bosch <stephan at rename-it.nl>
date: Fri Dec 13 21:35:58 2013 +0100
description:
Sieve extprograms plugin: Fixed fd leak and handling of output shutdown.
Output stream remained open, including the flush io, causing a second assert failure.
Whether this fixes the problem entirely remains to be seen.
diffstat:
src/plugins/sieve-extprograms/script-client-local.c | 1 -
src/plugins/sieve-extprograms/script-client.c | 23 +++++++++++++++++---
2 files changed, 19 insertions(+), 5 deletions(-)
diffs (65 lines):
diff -r bb3fbd27372a -r 61772824b4ea src/plugins/sieve-extprograms/script-client-local.c
--- a/src/plugins/sieve-extprograms/script-client-local.c Wed Nov 20 19:34:28 2013 +0100
+++ b/src/plugins/sieve-extprograms/script-client-local.c Fri Dec 13 21:35:58 2013 +0100
@@ -139,7 +139,6 @@
i_error("shutdown(%s, SHUT_WR) failed: %m", sclient->path);
return -1;
}
- sclient->fd_out = -1;
return 1;
}
diff -r bb3fbd27372a -r 61772824b4ea src/plugins/sieve-extprograms/script-client.c
--- a/src/plugins/sieve-extprograms/script-client.c Wed Nov 20 19:34:28 2013 +0100
+++ b/src/plugins/sieve-extprograms/script-client.c Fri Dec 13 21:35:58 2013 +0100
@@ -39,6 +39,20 @@
return 1;
}
+static int script_client_close_output(struct script_client *sclient)
+{
+ int ret;
+
+ if ( (ret=sclient->close_output(sclient)) < 0 )
+ return -1;
+ if ( sclient->script_output != NULL )
+ o_stream_destroy(&sclient->script_output);
+ sclient->script_output = NULL;
+ sclient->fd_out = -1;
+
+ return ret;
+}
+
static void script_client_disconnect
(struct script_client *sclient, bool force)
{
@@ -50,7 +64,7 @@
if ( sclient->disconnected )
return;
- if ( (ret=sclient->close_output(sclient)) < 0 )
+ if ( (ret=script_client_close_output(sclient)) < 0 )
error = TRUE;
if ( (ret=sclient->disconnect(sclient, force)) < 0 )
@@ -68,7 +82,8 @@
if (sclient->fd_in != -1 && close(sclient->fd_in) < 0)
i_error("close(%s) failed: %m", sclient->path);
- if (sclient->fd_out != -1 && sclient->fd_out != sclient->fd_out)
+ if (sclient->fd_out != -1 && sclient->fd_out != sclient->fd_in
+ && close(sclient->fd_out) < 0)
i_error("close(%s/out) failed: %m", sclient->path);
sclient->fd_in = sclient->fd_out = -1;
@@ -147,8 +162,8 @@
if ( sclient->script_input == NULL ) {
script_client_disconnect(sclient, FALSE);
- } else {
- sclient->close_output(sclient);
+ } else if (script_client_close_output(sclient) < 0) {
+ return -1;
}
return 0;
}
More information about the dovecot-cvs
mailing list