[dovecot-cvs] dovecot/src/imap client.c, 1.66, 1.67 client.h, 1.35,
1.36 cmd-append.c, 1.78, 1.79 cmd-idle.c, 1.29,
1.30 cmd-logout.c, 1.11, 1.12
cras at dovecot.org
cras at dovecot.org
Mon Mar 6 22:34:45 EET 2006
Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv24836/imap
Modified Files:
client.c client.h cmd-append.c cmd-idle.c cmd-logout.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/imap/client.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- client.c 26 Feb 2006 10:05:05 -0000 1.66
+++ client.c 6 Mar 2006 20:34:43 -0000 1.67
@@ -60,13 +60,19 @@
return client;
}
-void client_destroy(struct client *client)
+void client_destroy(struct client *client, const char *reason)
{
int ret;
i_assert(!client->destroyed);
client->destroyed = TRUE;
+ if (!client->disconnected) {
+ if (reason == NULL)
+ reason = "Disconnected";
+ i_info("%s", reason);
+ }
+
if (client->command_pending) {
/* try to deinitialize the command */
i_assert(client->cmd.func != NULL);
@@ -105,8 +111,13 @@
io_loop_stop(ioloop);
}
-void client_disconnect(struct client *client)
+void client_disconnect(struct client *client, const char *reason)
{
+ if (client->disconnected)
+ return;
+
+ i_info("Disconnected: %s", reason);
+ client->disconnected = TRUE;
(void)o_stream_flush(client->output);
i_stream_close(client->input);
@@ -116,7 +127,7 @@
void client_disconnect_with_error(struct client *client, const char *msg)
{
client_send_line(client, t_strconcat("* BYE ", msg, NULL));
- client_disconnect(client);
+ client_disconnect(client, msg);
}
int client_send_line(struct client *client, const char *data)
@@ -396,7 +407,7 @@
switch (i_stream_read(client->input)) {
case -1:
/* disconnected */
- client_destroy(client);
+ client_destroy(client, NULL);
return;
case -2:
/* parameter word is longer than max. input buffer size.
@@ -421,7 +432,7 @@
client->input_pending = TRUE;
if (client->output->closed)
- client_destroy(client);
+ client_destroy(client, NULL);
}
int _client_output(void *context)
@@ -434,7 +445,7 @@
client->last_output = ioloop_time;
if ((ret = o_stream_flush(client->output)) < 0) {
- client_destroy(client);
+ client_destroy(client, NULL);
return 1;
}
@@ -479,14 +490,15 @@
o_stream_get_buffer_used_size(my_client->output) > 0 &&
idle_time >= CLIENT_OUTPUT_TIMEOUT) {
/* client isn't reading our output */
- client_destroy(my_client);
+ client_destroy(my_client, "Disconnected for inactivity "
+ "in reading our output");
} else if (idle_time >= CLIENT_IDLE_TIMEOUT) {
/* client isn't sending us anything */
if (!my_client->command_pending) {
client_send_line(my_client,
"* BYE Disconnected for inactivity.");
}
- client_destroy(my_client);
+ client_destroy(my_client, "Disconnected for inactivity");
}
}
@@ -500,7 +512,7 @@
{
if (my_client != NULL) {
client_send_line(my_client, "* BYE Server shutting down.");
- client_destroy(my_client);
+ client_destroy(my_client, "Server shutting down");
}
timeout_remove(&to_idle);
Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- client.h 29 Jan 2006 12:41:37 -0000 1.35
+++ client.h 6 Mar 2006 20:34:43 -0000 1.36
@@ -46,6 +46,7 @@
struct imap_parser *parser;
struct client_command_context cmd;
+ unsigned int disconnected:1;
unsigned int destroyed:1;
unsigned int command_pending:1;
unsigned int input_pending:1;
@@ -59,10 +60,10 @@
if the handle is a socket. */
struct client *client_create(int fd_in, int fd_out,
struct namespace *namespaces);
-void client_destroy(struct client *client);
+void client_destroy(struct client *client, const char *reason);
/* Disconnect client connection */
-void client_disconnect(struct client *client);
+void client_disconnect(struct client *client, const char *reason);
void client_disconnect_with_error(struct client *client, const char *msg);
/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
Index: cmd-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- cmd-append.c 22 Feb 2006 16:02:28 -0000 1.78
+++ cmd-append.c 6 Mar 2006 20:34:43 -0000 1.79
@@ -40,7 +40,7 @@
case -1:
/* disconnected */
cmd_append_finish(cmd->context);
- client_destroy(client);
+ client_destroy(client, "Disconnected in APPEND");
return;
case -2:
cmd_append_finish(cmd->context);
Index: cmd-idle.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-idle.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- cmd-idle.c 6 Mar 2006 20:13:39 -0000 1.29
+++ cmd-idle.c 6 Mar 2006 20:34:43 -0000 1.30
@@ -80,7 +80,7 @@
switch (i_stream_read(client->input)) {
case -1:
/* disconnected */
- client_destroy(client);
+ client_destroy(client, "Disconnected in IDLE");
return;
case -2:
client->input_skip_line = TRUE;
Index: cmd-logout.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-logout.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cmd-logout.c 14 Jan 2006 18:47:21 -0000 1.11
+++ cmd-logout.c 6 Mar 2006 20:34:43 -0000 1.12
@@ -19,6 +19,6 @@
}
client_send_tagline(cmd, "OK Logout completed.");
- client_disconnect(client);
+ client_disconnect(client, "Logged out");
return TRUE;
}
More information about the dovecot-cvs
mailing list