dovecot-2.0-sslstream: dsync: Avoid hanging.

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:56:24 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/05893dd71338
changeset: 10325:05893dd71338
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 13 16:55:03 2009 -0500
description:
dsync: Avoid hanging.

diffstat:

3 files changed, 16 insertions(+), 6 deletions(-)
src/dsync/dsync-proxy-server-cmd.c      |    1 +
src/dsync/dsync-proxy-server.c          |   17 +++++++++++------
src/dsync/test-dsync-proxy-server-cmd.c |    4 ++++

diffs (79 lines):

diff -r 513cff2a7008 -r 05893dd71338 src/dsync/dsync-proxy-server-cmd.c
--- a/src/dsync/dsync-proxy-server-cmd.c	Fri Nov 13 16:54:48 2009 -0500
+++ b/src/dsync/dsync-proxy-server-cmd.c	Fri Nov 13 16:55:03 2009 -0500
@@ -9,6 +9,7 @@
 #include "istream-dot.h"
 #include "ostream.h"
 #include "imap-util.h"
+#include "master-service.h"
 #include "dsync-worker.h"
 #include "dsync-proxy.h"
 #include "dsync-proxy-server.h"
diff -r 513cff2a7008 -r 05893dd71338 src/dsync/dsync-proxy-server.c
--- a/src/dsync/dsync-proxy-server.c	Fri Nov 13 16:54:48 2009 -0500
+++ b/src/dsync/dsync-proxy-server.c	Fri Nov 13 16:55:03 2009 -0500
@@ -103,6 +103,8 @@ static void proxy_server_input(struct ds
 			break;
 	}
 	o_stream_uncork(server->output);
+	if (server->output->closed)
+		ret = -1;
 
 	if (ret < 0)
 		master_service_stop(master_service);
@@ -114,20 +116,23 @@ static int proxy_server_output(struct ds
 	int ret;
 
 	if ((ret = o_stream_flush(output)) < 0)
-		return 1;
-
-	if (server->cur_cmd != NULL) {
+		ret = 1;
+	else if (server->cur_cmd != NULL) {
 		o_stream_cork(output);
 		(void)proxy_server_run_cmd(server);
 		o_stream_uncork(output);
 
-		if (server->cur_cmd == NULL && server->io == NULL) {
-			server->io = io_add(server->fd_in, IO_READ,
-					    proxy_server_input, server);
+		if (server->cur_cmd == NULL) {
+			if (server->io == NULL) {
+				server->io = io_add(server->fd_in, IO_READ,
+						    proxy_server_input, server);
+			}
 			/* handle pending input */
 			proxy_server_input(server);
 		}
 	}
+	if (output->closed)
+		master_service_stop(master_service);
 	return ret;
 }
 
diff -r 513cff2a7008 -r 05893dd71338 src/dsync/test-dsync-proxy-server-cmd.c
--- a/src/dsync/test-dsync-proxy-server-cmd.c	Fri Nov 13 16:54:48 2009 -0500
+++ b/src/dsync/test-dsync-proxy-server-cmd.c	Fri Nov 13 16:55:03 2009 -0500
@@ -6,6 +6,7 @@
 #include "strescape.h"
 #include "istream.h"
 #include "ostream.h"
+#include "master-service.h"
 #include "test-common.h"
 #include "dsync-proxy-server.h"
 #include "test-dsync-worker.h"
@@ -13,11 +14,14 @@
 
 #define ALL_MAIL_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft \\Recent"
 
+struct master_service *master_service;
 static string_t *out;
 static struct dsync_proxy_server *server;
 static struct test_dsync_worker *test_worker;
 static struct dsync_proxy_server_command *cur_cmd;
 static const char *cur_cmd_args[20];
+
+void master_service_stop(struct master_service *service ATTR_UNUSED) {}
 
 static void out_clear(void)
 {


More information about the dovecot-cvs mailing list