[dovecot-cvs] dovecot/src/pop3 client.c, 1.63, 1.64 client.h, 1.12, 1.13 commands.c, 1.52, 1.53

cras at dovecot.org cras at dovecot.org
Mon Mar 6 22:34:46 EET 2006


Update of /var/lib/cvs/dovecot/src/pop3
In directory talvi:/tmp/cvs-serv24836/pop3

Modified Files:
	client.c client.h commands.c 
Log Message:
Log a line when IMAP client disconnects with a reason why it happened.
Changed the reason strings also a bit with POP3.



Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- client.c	26 Feb 2006 10:05:28 -0000	1.63
+++ client.c	6 Mar 2006 20:34:42 -0000	1.64
@@ -158,7 +158,7 @@
 			mail_storage_get_last_error(storage, &syntax_error,
 						    &temporary_error));
 		client_send_line(client, "-ERR No INBOX for user.");
-		client_destroy(client, "No INBOX for user.");
+		client_destroy(client, "No INBOX for user");
 		return NULL;
 	}
 
@@ -208,8 +208,11 @@
 
 void client_destroy(struct client *client, const char *reason)
 {
-	if (reason != NULL)
+	if (!client->disconnected) {
+		if (reason == NULL)
+			reason = "Disconnected";
 		i_info("%s %s", reason, client_stats(client));
+	}
 
 	if (client->cmd != NULL) {
 		/* deinitialize command */
@@ -249,8 +252,11 @@
 
 void client_disconnect(struct client *client, const char *reason)
 {
-	if (reason != NULL)
-		i_info("%s %s", reason, client_stats(client));
+	if (client->disconnected)
+		return;
+
+	client->disconnected = TRUE;
+	i_info("Disconnected: %s %s", reason, client_stats(client));
 
 	(void)o_stream_flush(client->output);
 
@@ -341,12 +347,12 @@
 	switch (i_stream_read(client->input)) {
 	case -1:
 		/* disconnected */
-		client_destroy(client, "Disconnected");
+		client_destroy(client, NULL);
 		return;
 	case -2:
 		/* line too long, kill it */
 		client_send_line(client, "-ERR Input line too long.");
-		client_destroy(client, "Input line too long.");
+		client_destroy(client, "Input line too long");
 		return;
 	}
 
@@ -420,14 +426,16 @@
 
 	if (my_client->cmd != NULL) {
 		if (ioloop_time - my_client->last_output >=
-		    CLIENT_OUTPUT_TIMEOUT)
-			client_destroy(my_client, "Disconnected for inactivity.");
+		    CLIENT_OUTPUT_TIMEOUT) {
+			client_destroy(my_client, "Disconnected for inactivity "
+				       "in reading our output");
+		}
 	} else {
 		if (ioloop_time - my_client->last_input >=
 		    CLIENT_IDLE_TIMEOUT) {
 			client_send_line(my_client,
 					 "-ERR Disconnected for inactivity.");
-			client_destroy(my_client, "Disconnected for inactivity.");
+			client_destroy(my_client, "Disconnected for inactivity");
 		}
 	}
 }
@@ -442,7 +450,7 @@
 {
 	if (my_client != NULL) {
 		client_send_line(my_client, "-ERR Server shutting down.");
-		client_destroy(my_client, "Server shutting down.");
+		client_destroy(my_client, "Server shutting down");
 	}
 
 	timeout_remove(&to_idle);

Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- client.h	29 Jan 2006 12:14:50 -0000	1.12
+++ client.h	6 Mar 2006 20:34:42 -0000	1.13
@@ -40,6 +40,7 @@
 
 	unsigned char *deleted_bitmask;
 
+	unsigned int disconnected:1;
 	unsigned int deleted:1;
 	unsigned int waiting_input:1;
 };

Index: commands.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/commands.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- commands.c	14 Jan 2006 18:48:17 -0000	1.52
+++ commands.c	6 Mar 2006 20:34:42 -0000	1.53
@@ -239,7 +239,7 @@
 	else
 		client_send_line(client, "+OK Logging out, messages deleted.");
 
-	client_disconnect(client, "Logout.");
+	client_disconnect(client, "Logged out");
 	return 1;
 }
 



More information about the dovecot-cvs mailing list