]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Avoid hanging.
authorTimo Sirainen <tss@iki.fi>
Fri, 13 Nov 2009 21:55:03 +0000 (16:55 -0500)
committerTimo Sirainen <tss@iki.fi>
Fri, 13 Nov 2009 21:55:03 +0000 (16:55 -0500)
--HG--
branch : HEAD

src/dsync/dsync-proxy-server-cmd.c
src/dsync/dsync-proxy-server.c
src/dsync/test-dsync-proxy-server-cmd.c

index fef95d9566a7d428512f23657816873abc3162ac..4032bc8cbc6102708b0715d2e224152b57ef2dd9 100644 (file)
@@ -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"
index fedb7d266aa19e415e6c90ffdb873675732e24c5..5e3eb334ec5b0aa0f1f325cc145cf386276a2a3a 100644 (file)
@@ -103,6 +103,8 @@ static void proxy_server_input(struct dsync_proxy_server *server)
                        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 dsync_proxy_server *server)
        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;
 }
 
index e213c0350764fb896c2160f4e4ef37baace6c083..7379f4e355a151772989d47788de1cfbbad9045b 100644 (file)
@@ -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"
 
 #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)
 {
        o_stream_seek(server->output, 0);