[PATCH 5/5] Track idling state and tell idled if we lose connection
Bron Gondwana
brong at fastmail.fm
Thu Sep 10 09:53:37 EDT 2009
We get a bunch of "process killed with signal 10" errors
after restarting one of our imap proxies, and it's because
idled goes a little crazy throwing SIGUSR1 and SIGUSR2 at
processids which have long since gone away. It's like a
loaded gun that randomly shoots whatever process was unlucky
enough to get that PID.
Now, the whole design sucks really - but at least the worst
of it will be fixed by telling idled that we've idle_done()
when we shut_down(), no matter how we got there.
---
imap/imapd.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/imap/imapd.c b/imap/imapd.c
index 8a32461..e4f7c63 100644
--- a/imap/imapd.c
+++ b/imap/imapd.c
@@ -208,6 +208,9 @@ static const int max_monthdays[] = {
31, 31, 30, 31, 30, 31
};
+/* track if we're idling */
+static int idling = 0;
+
void motd_file(int fd);
void shut_down(int code);
void fatal(const char *s, int code);
@@ -870,6 +873,9 @@ void shut_down(int code)
}
if (backend_cached) free(backend_cached);
+ if (idling)
+ idle_done(imapd_mailbox ? imapd_mailbox->name : NULL);
+
if (imapd_mailbox) {
index_closemailbox(imapd_mailbox);
mailbox_close(imapd_mailbox);
@@ -2549,11 +2555,15 @@ void cmd_idle(char *tag)
/* Start doing mailbox updates */
if (imapd_mailbox) index_check(imapd_mailbox, 0, 1);
idle_start(imapd_mailbox ? imapd_mailbox->name : NULL);
+ /* use this flag so if getc causes a shutdown due to
+ * connection abort we tell idled about it */
+ idling = 1;
/* Get continuation data */
c = getword(imapd_in, &arg);
/* Stop updates and do any necessary cleanup */
+ idling = 0;
idle_done(imapd_mailbox ? imapd_mailbox->name : NULL);
}
else { /* Remote mailbox */
--
1.6.2.2.446.gfbdc0
More information about the Cyrus-devel
mailing list