[dovecot-cvs] dovecot/src/imap client.c,1.26,1.27 client.h,1.13,1.14 cmd-close.c,1.6,1.7 cmd-idle.c,1.1,1.2 cmd-select.c,1.16,1.17 cmd-unselect.c,1.1,1.2 commands-util.c,1.22,1.23 commands-util.h,1.10,1.11 common.h,1.5,1.6
cras at procontrol.fi
cras at procontrol.fi
Thu Feb 20 02:46:19 EET 2003
Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv9318/src/imap
Modified Files:
client.c client.h cmd-close.c cmd-idle.c cmd-select.c
cmd-unselect.c commands-util.c commands-util.h common.h
Log Message:
workaround: outlook-idle
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- client.c 14 Feb 2003 10:46:44 -0000 1.26
+++ client.c 20 Feb 2003 00:46:17 -0000 1.27
@@ -22,9 +22,6 @@
/* Disconnect client when it sends too many bad commands in a row */
#define CLIENT_MAX_BAD_COMMANDS 20
-/* Disconnect client after idling this many seconds */
-#define CLIENT_IDLE_TIMEOUT (60*30)
-
extern struct mail_storage_callbacks mail_storage_callbacks;
static struct client *my_client; /* we don't need more than one currently */
@@ -91,6 +88,9 @@
imap_parser_destroy(client->parser);
io_remove(client->io);
+
+ if (client->idle_to != NULL)
+ timeout_remove(client->idle_to);
i_stream_unref(client->input);
o_stream_unref(client->output);
Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- client.h 14 Feb 2003 10:46:44 -0000 1.13
+++ client.h 20 Feb 2003 00:46:17 -0000 1.14
@@ -34,6 +34,9 @@
const char *cmd_name; /* command name (allocated from parser pool) */
client_command_func_t *cmd_func;
+ struct timeout *idle_to;
+ unsigned int idle_expunge;
+
unsigned int cmd_error:1;
unsigned int cmd_uid:1; /* used UID command */
unsigned int sync_flags_send_uid:1;
Index: cmd-close.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-close.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmd-close.c 22 Jan 2003 20:46:36 -0000 1.6
+++ cmd-close.c 20 Feb 2003 00:46:17 -0000 1.7
@@ -5,16 +5,18 @@
int cmd_close(struct client *client)
{
+ struct mailbox *mailbox = client->mailbox;
+
if (!client_verify_open_mailbox(client))
return TRUE;
- if (!client->mailbox->expunge(client->mailbox, FALSE))
- client_send_closing_mailbox_error(client);
+ client->mailbox = NULL;
- if (!client->mailbox->close(client->mailbox))
- client_send_closing_mailbox_error(client);
+ if (!mailbox->expunge(mailbox, FALSE))
+ client_send_untagged_storage_error(client);
- client->mailbox = NULL;
+ if (!mailbox->close(mailbox))
+ client_send_untagged_storage_error(client);
client_send_tagline(client, "OK Close completed.");
return TRUE;
Index: cmd-idle.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-idle.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmd-idle.c 14 Feb 2003 10:46:44 -0000 1.1
+++ cmd-idle.c 20 Feb 2003 00:46:17 -0000 1.2
@@ -11,6 +11,16 @@
static void idle_finish(struct client *client)
{
+ if (client->idle_to != NULL) {
+ timeout_remove(client->idle_to);
+ client->idle_to = NULL;
+ }
+
+ if (client->idle_expunge) {
+ client_send_line(client,
+ t_strdup_printf("* %u EXPUNGE", client->idle_expunge));
+ }
+
io_remove(client->io);
client->io = io_add(i_stream_get_fd(client->input),
IO_READ, _client_input, client);
@@ -60,6 +70,25 @@
}
}
+static void idle_timeout(void *context)
+{
+ struct client *client = context;
+ struct mailbox_status status;
+
+ timeout_remove(client->idle_to);
+ client->idle_to = NULL;
+
+ if (!client->mailbox->get_status(client->mailbox, STATUS_MESSAGES,
+ &status)) {
+ client_send_untagged_storage_error(client);
+ idle_finish(client);
+ } else {
+ client->idle_expunge = status.messages+1;
+ client_send_line(client,
+ t_strdup_printf("* %u EXISTS", client->idle_expunge));
+ }
+}
+
int cmd_idle(struct client *client)
{
const char *str;
@@ -67,6 +96,12 @@
if (!client_verify_open_mailbox(client))
return TRUE;
+
+ client->idle_expunge = 0;
+ if ((client_workarounds & WORKAROUND_OUTLOOK_IDLE) != 0) {
+ client->idle_to = timeout_add((CLIENT_IDLE_TIMEOUT - 60) * 1000,
+ idle_timeout, client);
+ }
str = getenv("MAILBOX_IDLE_CHECK_INTERVAL");
interval = str == NULL ? 0 : (unsigned int)strtoul(str, NULL, 10);
Index: cmd-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-select.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cmd-select.c 14 Feb 2003 10:46:44 -0000 1.16
+++ cmd-select.c 20 Feb 2003 00:46:17 -0000 1.17
@@ -14,9 +14,10 @@
return FALSE;
if (client->mailbox != NULL) {
- if (!client->mailbox->close(client->mailbox))
- client_send_closing_mailbox_error(client);
+ box = client->mailbox;
client->mailbox = NULL;
+ if (!box->close(box))
+ client_send_untagged_storage_error(client);
}
box = client->storage->open_mailbox(client->storage, mailbox,
Index: cmd-unselect.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-unselect.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmd-unselect.c 23 Jan 2003 19:02:10 -0000 1.1
+++ cmd-unselect.c 20 Feb 2003 00:46:17 -0000 1.2
@@ -5,13 +5,15 @@
int cmd_unselect(struct client *client)
{
+ struct mailbox *mailbox = client->mailbox;
+
if (!client_verify_open_mailbox(client))
return TRUE;
- if (!client->mailbox->close(client->mailbox))
- client_send_closing_mailbox_error(client);
-
client->mailbox = NULL;
+
+ if (!mailbox->close(mailbox))
+ client_send_untagged_storage_error(client);
client_send_tagline(client, "OK Unselect completed.");
return TRUE;
Index: commands-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- commands-util.c 14 Feb 2003 08:00:52 -0000 1.22
+++ commands-util.c 20 Feb 2003 00:46:17 -0000 1.23
@@ -121,10 +121,18 @@
error, NULL));
}
-void client_send_closing_mailbox_error(struct client *client)
+void client_send_untagged_storage_error(struct client *client)
{
const char *error;
int syntax;
+
+ if (client->mailbox != NULL &&
+ client->mailbox->is_inconsistency_error(client->mailbox)) {
+ /* we can't do forced CLOSE, so have to disconnect */
+ client_disconnect_with_error(client,
+ "Mailbox is in inconsistent state, please relogin.");
+ return;
+ }
error = client->storage->get_last_error(client->storage, &syntax);
client_send_line(client,
Index: commands-util.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/commands-util.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- commands-util.h 14 Feb 2003 08:00:52 -0000 1.10
+++ commands-util.h 20 Feb 2003 00:46:17 -0000 1.11
@@ -26,9 +26,8 @@
/* Send last mail storage error message to client. */
void client_send_storage_error(struct client *client);
-/* Send untagged error message to client. Doesn't check for inconsistency,
- so should be called only by CLOSE, SELECT and UNSELECT. */
-void client_send_closing_mailbox_error(struct client *client);
+/* Send untagged error message to client. */
+void client_send_untagged_storage_error(struct client *client);
/* Parse flags. Returns TRUE if successful, if not sends an error message to
client. */
Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/common.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- common.h 14 Feb 2003 10:46:44 -0000 1.5
+++ common.h 20 Feb 2003 00:46:17 -0000 1.6
@@ -8,6 +8,9 @@
for command from user is around MAX_INBUF_SIZE * MAX_IMAP_ARG_ELEMENTS */
#define MAX_IMAP_ARG_ELEMENTS 128
+/* Disconnect client after idling this many seconds */
+#define CLIENT_IDLE_TIMEOUT (60*30)
+
#define DEFAULT_MAX_CUSTOM_FLAG_LENGTH 50
extern struct ioloop *ioloop;
More information about the dovecot-cvs
mailing list