Skip to content

Commit

Permalink
IMAP: allow setting interval between keepalive messages during IDLE
Browse files Browse the repository at this point in the history
setting this to a high value will improve battery life for mobile
clients like K-9, and allow thunderbird to keep IDLE session IDLE
for longer. Make sure imap_timeout * imap_interval < 1800 (30
minutes)
  • Loading branch information
pjstevns committed May 10, 2012
1 parent ede5490 commit 518024b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dbmail.conf
Expand Up @@ -271,6 +271,15 @@ imap_before_smtp = no
#
# idle_timeout = 30

# during IDLE, how often should the server send an '* OK' still
# here message (default: 10)
#
# the time between such a message is idle_timeout * idle_interval
# seconds
#
# idle_interval = 10


#
# Provide a CAPABILITY to override the default
#
Expand Down
11 changes: 10 additions & 1 deletion src/imap4.c
Expand Up @@ -227,12 +227,21 @@ static void send_greeting(ImapSession *session)

void imap_cb_time(void *arg)
{
Field_T interval;
int idle_interval = 10;
ImapSession *session = (ImapSession *) arg;
TRACE(TRACE_DEBUG,"[%p]", session);

if ( session->command_type == IMAP_COMM_IDLE && session->command_state == IDLE ) { // session is in a IDLE loop
GETCONFIGVALUE("idle_interval", "IMAP", interval);
if (strlen(interval) > 0) {
int i = atoi(interval);
if (i > 0 && i < 1000)
idle_interval = i;
}

ci_cork(session->ci);
if (! (session->loop++ % 10)) {
if (! (++session->loop % idle_interval)) {
imap_session_printf(session, "* OK\r\n");
}
dbmail_imap_session_mailbox_status(session,TRUE);
Expand Down

0 comments on commit 518024b

Please sign in to comment.