changeset 3871:2506e4077e7a HEAD

Don't crash if closing with signal while IDLEing.
author Timo Sirainen <tss@iki.fi>
date Sat, 14 Jan 2006 16:51:29 +0200
parents 099ea3b43ee2
children b054cd10ceaa
files src/imap/client.c src/imap/client.h
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/client.c	Sat Jan 14 16:09:05 2006 +0200
+++ b/src/imap/client.c	Sat Jan 14 16:51:29 2006 +0200
@@ -62,11 +62,16 @@
 {
 	int ret;
 
+	i_assert(!client->destroyed);
+	client->destroyed = TRUE;
+
 	if (client->command_pending) {
 		/* try to deinitialize the command */
 		i_assert(client->cmd.func != NULL);
 		i_stream_close(client->input);
 		o_stream_close(client->output);
+		client->input_pending = FALSE;
+
 		ret = client->cmd.func(&client->cmd);
 		i_assert(ret);
 	}
@@ -268,7 +273,7 @@
 	   pending and we should get around to calling client_input() soon.
 	   This is mostly for APPEND/IDLE. */
 	(void)i_stream_get_data(client->input, &size);
-	if (size > 0)
+	if (size > 0 && !client->destroyed)
 		client->input_pending = TRUE;
 }
 
--- a/src/imap/client.h	Sat Jan 14 16:09:05 2006 +0200
+++ b/src/imap/client.h	Sat Jan 14 16:51:29 2006 +0200
@@ -46,6 +46,7 @@
 	struct imap_parser *parser;
 	struct client_command_context cmd;
 
+	unsigned int destroyed:1;
 	unsigned int command_pending:1;
 	unsigned int input_pending:1;
 	unsigned int output_pending:1;