changeset 5114:7413b8e0d765 HEAD

hangfix
author Timo Sirainen <tss@iki.fi>
date Tue, 06 Feb 2007 20:50:52 +0200
parents 92ce1b337b50
children 0c89a2f72f86
files src/imap/client.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/client.c	Tue Feb 06 18:01:23 2007 +0200
+++ b/src/imap/client.c	Tue Feb 06 20:50:52 2007 +0200
@@ -397,6 +397,15 @@
 	}
 }
 
+static void client_add_missing_io(struct client *client)
+{
+	if (client->io == NULL) {
+		i_assert(i_stream_get_fd(client->input) >= 0);
+		client->io = io_add(i_stream_get_fd(client->input),
+				    IO_READ, _client_input, client);
+	}
+}
+
 void client_continue_pending_input(struct client *client)
 {
 	size_t size;
@@ -417,11 +426,7 @@
 			return;
 	}
 
-	if (client->io == NULL) {
-		i_assert(i_stream_get_fd(client->input) >= 0);
-		client->io = io_add(i_stream_get_fd(client->input),
-				    IO_READ, _client_input, client);
-	}
+	client_add_missing_io(client);
 
 	/* if there's unread data in buffer, handle it. */
 	(void)i_stream_get_data(client->input, &size);
@@ -459,6 +464,7 @@
 		if (cmd->func(cmd) || cmd->param_error) {
 			/* command execution was finished */
 			client_command_free(cmd);
+			client_add_missing_io(client);
 			return TRUE;
 		}
 
@@ -553,6 +559,8 @@
 	struct client_command_context *cmd;
 	int ret;
 
+	i_assert(client->io != NULL);
+
 	client->last_input = ioloop_time;
 
 	switch (i_stream_read(client->input)) {