From d347e07837c4c84d97ad1c2ba13917ec6846f7ef Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 27 Oct 2016 12:27:45 -0400 Subject: [PATCH 1/9] Add daemon flag (-d). --- child-fetch.c | 13 +++++++++++++ fdm.1 | 4 +++- fdm.c | 13 +++++++++++-- fdm.h | 1 + fetch.h | 1 + imap-common.c | 7 +++++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/child-fetch.c b/child-fetch.c index f33b7a5a..e400ae7b 100644 --- a/child-fetch.c +++ b/child-fetch.c @@ -339,6 +339,7 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) struct iolist iol; int aborted, complete, holding, timeout; +restart: log_debug2("%s: fetching", a->name); TAILQ_INIT(&fetch_matchq); @@ -425,6 +426,11 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) /* Fetch again - no blocking. */ log_debug3("%s: fetch, again", a->name); continue; + case FETCH_RESTART: + log_debug("%s: sleeping",a->name); + sleep(5); // For debugging. Change to 300 + log_debug("%s: fetch, again",a->name); + continue; case FETCH_BLOCK: /* Fetch again - allow blocking. */ log_debug3("%s: fetch, block", a->name); @@ -497,6 +503,13 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) db_close(cache->db); } + /* In daemon mode, always try to restart. */ + /* If there were errors here, we could add a re-try limit. */ + if (conf.daemon) { + sleep(5); + goto restart; + } + /* Print results. */ if (nflags & FETCH_POLL) log_info("%s: %u messages found", a->name, a->fetch->total(a)); diff --git a/fdm.1 b/fdm.1 index ca62b26a..2b99c40e 100644 --- a/fdm.1 +++ b/fdm.1 @@ -23,7 +23,7 @@ .Sh SYNOPSIS .Nm fdm .Bk -words -.Op Fl hklmnqv +.Op Fl dhklmnqv .Op Fl a Ar account .Op Fl D Ar name Ns = Ns Ar value .Op Fl f Ar conffile @@ -59,6 +59,8 @@ Default is or .Pa /etc/fdm.conf if that doesn't exist. +.It Fl d +Run in daemon mode. Loop through accounts with a second delay. .It Fl h Look at the .Ev HOME diff --git a/fdm.c b/fdm.c index cdf8383b..e08ac1da 100644 --- a/fdm.c +++ b/fdm.c @@ -266,7 +266,7 @@ __dead void usage(void) { fprintf(stderr, - "usage: %s [-hklmnqv] [-a name] [-D name=value] [-f conffile] " + "usage: %s [-dhklmnqv] [-a name] [-D name=value] [-f conffile] " "[-u user] [-x name] [fetch|poll|cache] [arguments]\n", __progname); exit(1); } @@ -326,6 +326,12 @@ main(int argc, char **argv) conf.def_user = NULL; conf.cmd_user = NULL; conf.max_accts = -1; + conf.keep_all = 0; + conf.daemon = 0; + conf.syslog = 0; + conf.allow_many = 0; + conf.check_only = 0; + conf.debug = 0; conf.strip_chars = xstrdup(DEFSTRIPCHARS); conf.user_order = xmalloc(sizeof *conf.user_order); @@ -336,7 +342,7 @@ main(int argc, char **argv) ARRAY_INIT(&conf.excl); ARRAY_INIT(¯os); - while ((opt = getopt(argc, argv, "a:D:f:hklmnqu:vx:")) != -1) { + while ((opt = getopt(argc, argv, "a:D:f:dhklmnqu:vx:")) != -1) { switch (opt) { case 'a': ARRAY_ADD(&conf.incl, xstrdup(optarg)); @@ -348,6 +354,9 @@ main(int argc, char **argv) if (conf.conf_file == NULL) conf.conf_file = xstrdup(optarg); break; + case 'd': + conf.daemon = 1; + break; case 'h': home = getenv("HOME"); break; diff --git a/fdm.h b/fdm.h index 5de799c2..86e6f194 100644 --- a/fdm.h +++ b/fdm.h @@ -613,6 +613,7 @@ struct conf { char *conf_file; char *strip_chars; + int daemon; int check_only; int allow_many; int keep_all; diff --git a/fetch.h b/fetch.h index 7529eba9..07922ae1 100644 --- a/fetch.h +++ b/fetch.h @@ -25,6 +25,7 @@ #define FETCH_ERROR 3 #define FETCH_MAIL 4 #define FETCH_EXIT 5 +#define FETCH_RESTART 6 /* Fetch flags. */ #define FETCH_PURGE 0x1 diff --git a/imap-common.c b/imap-common.c index de627722..6c8f629f 100644 --- a/imap-common.c +++ b/imap-common.c @@ -1120,9 +1120,16 @@ imap_state_close(struct account *a, struct fetch_ctx *fctx) return (FETCH_AGAIN); } + if (conf.daemon) { + data->folder = 0; // go back to the first folder. + fctx->state = imap_state_select1; + return (FETCH_RESTART); + } + if (imap_putln(a, "%u LOGOUT", ++data->tag) != 0) return (FETCH_ERROR); fctx->state = imap_state_quit; + return (FETCH_BLOCK); } From 93505a216acdd92cf53766ad2b817335df03b3ff Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 25 Oct 2016 11:33:08 -0400 Subject: [PATCH 2/9] Initial daemon mode implementation. Added FETCH_RESTART state to restart fetch from the beginning with a delay. IMAP returns FETCH_RESTART without logging out in daemon mode. POP3 will log out and close, but child_fetch.c should restart it. (have not tested pop3) If FETCH_ERROR is received in daemon mode, attempt to restart after a delay. --- fdm.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdm.1 b/fdm.1 index 2b99c40e..870199a7 100644 --- a/fdm.1 +++ b/fdm.1 @@ -60,7 +60,7 @@ or .Pa /etc/fdm.conf if that doesn't exist. .It Fl d -Run in daemon mode. Loop through accounts with a second delay. +Run in daemon mode. Loop through accounts with a delay. .It Fl h Look at the .Ev HOME From cab82254bab9dd82f57fd561f5e5b2dc2c706a46 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 27 Oct 2016 09:22:36 -0400 Subject: [PATCH 3/9] Fork with daemon() and log to syslog in daemon mode. --- fdm.1 | 5 +++++ fdm.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/fdm.1 b/fdm.1 index 870199a7..0fdaaa6f 100644 --- a/fdm.1 +++ b/fdm.1 @@ -61,6 +61,11 @@ or if that doesn't exist. .It Fl d Run in daemon mode. Loop through accounts with a delay. +Implies +.Fl l . +Daemon mode is only compatible with the +.Ic fetch +command. .It Fl h Look at the .Ev HOME diff --git a/fdm.c b/fdm.c index e08ac1da..ea017659 100644 --- a/fdm.c +++ b/fdm.c @@ -356,6 +356,7 @@ main(int argc, char **argv) break; case 'd': conf.daemon = 1; + conf.syslog = 1; break; case 'h': home = getenv("HOME"); @@ -412,6 +413,15 @@ main(int argc, char **argv) usage(); } + /* fork off into daemon mode if requested. */ + if (conf.daemon) { + if (op != FDMOP_FETCH) + fatal("Fetch command must be given for daemon mode."); + + if (daemon(1,0)) + fatal("Daemon mode failed."); + } + /* Set debug level and start logging to syslog if necessary. */ if (conf.syslog) log_open_syslog(conf.debug); From 27a4361ed9adabb83c61807a01c07e905fec77df Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 27 Oct 2016 10:17:46 -0400 Subject: [PATCH 4/9] Change to root directory on call to daemon(). --- fdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdm.c b/fdm.c index ea017659..c858d5e9 100644 --- a/fdm.c +++ b/fdm.c @@ -418,7 +418,7 @@ main(int argc, char **argv) if (op != FDMOP_FETCH) fatal("Fetch command must be given for daemon mode."); - if (daemon(1,0)) + if (daemon(0,0)) fatal("Daemon mode failed."); } From aec40989d56f712cce3e34368738608c31ff700c Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 27 Oct 2016 13:05:31 -0400 Subject: [PATCH 5/9] Add fetch-frequency configuration option. --- child-fetch.c | 19 +++++++++---------- fdm.c | 1 + fdm.h | 2 ++ lex.c | 1 + parse.y | 5 +++++ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/child-fetch.c b/child-fetch.c index e400ae7b..a40ddc00 100644 --- a/child-fetch.c +++ b/child-fetch.c @@ -428,8 +428,8 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) continue; case FETCH_RESTART: log_debug("%s: sleeping",a->name); - sleep(5); // For debugging. Change to 300 - log_debug("%s: fetch, again",a->name); + sleep(conf.fetch_freq); + log_debug("%s: fetch, restart",a->name); continue; case FETCH_BLOCK: /* Fetch again - allow blocking. */ @@ -503,19 +503,18 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) db_close(cache->db); } - /* In daemon mode, always try to restart. */ - /* If there were errors here, we could add a re-try limit. */ - if (conf.daemon) { - sleep(5); - goto restart; - } - /* Print results. */ if (nflags & FETCH_POLL) log_info("%s: %u messages found", a->name, a->fetch->total(a)); else fetch_status(a, tim); - return (aborted); + + /* In daemon mode, always try to restart. */ + if (conf.daemon) { + sleep(conf.fetch_freq); + goto restart; + } else + return (aborted); } /* diff --git a/fdm.c b/fdm.c index c858d5e9..b51a4ac7 100644 --- a/fdm.c +++ b/fdm.c @@ -332,6 +332,7 @@ main(int argc, char **argv) conf.allow_many = 0; conf.check_only = 0; conf.debug = 0; + conf.fetch_freq = DEFFETCHFREQ; conf.strip_chars = xstrdup(DEFSTRIPCHARS); conf.user_order = xmalloc(sizeof *conf.user_order); diff --git a/fdm.h b/fdm.h index 86e6f194..93944296 100644 --- a/fdm.h +++ b/fdm.h @@ -56,6 +56,7 @@ #define CONFFILE ".fdm.conf" #define LOCKFILE ".fdm.lock" #define DEFLOCKTIMEOUT 10 +#define DEFFETCHFREQ 60 * 5 /* 5 minutes */ #define MAXQUEUEVALUE 50 #define DEFMAILQUEUE 2 #define DEFMAILSIZE (32 * 1024 * 1024) /* 32 MB */ @@ -636,6 +637,7 @@ struct conf { size_t max_size; int timeout; + int fetch_freq; int del_big; int ignore_errors; u_int lock_types; diff --git a/lex.c b/lex.c index c5de0b09..0b8d5779 100644 --- a/lex.c +++ b/lex.c @@ -95,6 +95,7 @@ static const struct token tokens[] = { { "exec", TOKEXEC }, { "expire", TOKEXPIRE }, { "fcntl", TOKFCNTL }, + { "fetch-frequency", TOKFETCHFREQ }, { "file-group", TOKFILEGROUP }, { "file-umask", TOKFILEUMASK }, { "flock", TOKFLOCK }, diff --git a/parse.y b/parse.y index ace50f8d..5d314981 100644 --- a/parse.y +++ b/parse.y @@ -155,6 +155,7 @@ yyerror(const char *fmt, ...) %token TOKEXEC %token TOKEXPIRE %token TOKFCNTL +%token TOKFETCHFREQ %token TOKFILEGROUP %token TOKFILEUMASK %token TOKFLOCK @@ -604,6 +605,10 @@ set: TOKSET TOKMAXSIZE size { conf.del_big = 1; } + | TOKSET TOKFETCHFREQ time + { + conf.fetch_freq = $3; + } | TOKSET TOKIGNOREERRORS { conf.ignore_errors = 1; From 0e30b26ec7fae3edc5ede3c4ed71458a25fcc1de Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 28 Oct 2016 15:19:37 -0400 Subject: [PATCH 6/9] Implement per-account timeout. --- fdm.h | 1 + fetch-imap.c | 13 ++++++++++--- fetch-pop3.c | 11 +++++++++-- parse.y | 14 ++++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/fdm.h b/fdm.h index 93944296..7fa6a803 100644 --- a/fdm.h +++ b/fdm.h @@ -490,6 +490,7 @@ struct account { int disabled; int keep; + int timeout; struct fetch *fetch; void *data; diff --git a/fetch-imap.c b/fetch-imap.c index 6c5fc01f..43d3a997 100644 --- a/fetch-imap.c +++ b/fetch-imap.c @@ -123,12 +123,19 @@ void fetch_imap_desc(struct account *a, char *buf, size_t len) { struct fetch_imap_data *data = a->data; - char *folders; + char *folders, timeout[18]; folders = fmt_strings("folders ", data->folders); + + if (a->timeout != 0) + snprintf(timeout,sizeof timeout," timeout %u", a->timeout); + else + timeout[0] = 0; + xsnprintf(buf, len, - "imap%s server \"%s\" port %s user \"%s\" %s", + "imap%s server \"%s\" port %s user \"%s\" %s%s%s", data->server.ssl ? "s" : "", data->server.host, data->server.port, - data->user, folders); + data->user, folders, + data->server.insecure ? " insecure" : "", timeout); xfree(folders); } diff --git a/fetch-pop3.c b/fetch-pop3.c index c45d7114..ca931351 100644 --- a/fetch-pop3.c +++ b/fetch-pop3.c @@ -127,8 +127,15 @@ void fetch_pop3_desc(struct account *a, char *buf, size_t len) { struct fetch_pop3_data *data = a->data; + char timeout[18]; - xsnprintf(buf, len, "pop3%s server \"%s\" port %s user \"%s\"", + if (a->timeout != 0) + snprintf(timeout,sizeof timeout," timeout %u", a->timeout); + else + timeout[0] = 0; + + xsnprintf(buf, len, "pop3%s server \"%s\" port %s user \"%s\"%s%s", data->server.ssl ? "s" : "", data->server.host, data->server.port, - data->user); + data->user, + data->server.insecure ? " insecure" : "", timeout); } diff --git a/parse.y b/parse.y index 5d314981..9f3a1ac5 100644 --- a/parse.y +++ b/parse.y @@ -311,7 +311,7 @@ yyerror(const char *fmt, ...) %type insecure %type localgid %type lock locklist -%type size time numv retrc expire +%type size time numv retrc expire timeout %type only imaponly %type poponly %type replstrslist actions rmheaders accounts users @@ -1065,6 +1065,15 @@ port: TOKPORT replstrv xasprintf(&$$, "%lld", $2); } +timeout: /* not present */ + { + $$ = 0; /* use global value */ + } + | TOKTIMEOUT time + { + $$ = $2; + } + server: TOKSERVER replstrv port { if (*$2 == '\0') @@ -2387,7 +2396,7 @@ fetchtype: poptype server userpassnetrc poponly apop verify uidl starttls data->server.ai = NULL; } -account: TOKACCOUNT replstrv disabled users fetchtype keep +account: TOKACCOUNT replstrv disabled users fetchtype keep timeout { struct account *a; char *su, desc[DESCBUFSIZE]; @@ -2402,6 +2411,7 @@ account: TOKACCOUNT replstrv disabled users fetchtype keep a = xcalloc(1, sizeof *a); strlcpy(a->name, $2, sizeof a->name); a->keep = $6; + a->timeout = $7; a->disabled = $3; a->users = $4; a->fetch = $5.fetch; From f68efd7ca6644f543557598c44054edbf81621d7 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 31 Oct 2016 17:59:25 -0400 Subject: [PATCH 7/9] Daemon mode: wait in fetch_poll(). --- child-fetch.c | 34 +++++++++++++++++++++++----------- fdm.h | 1 + fetch.h | 2 +- imap-common.c | 3 ++- io.c | 2 +- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/child-fetch.c b/child-fetch.c index a40ddc00..4af5964d 100644 --- a/child-fetch.c +++ b/child-fetch.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "fdm.h" #include "deliver.h" @@ -134,10 +135,13 @@ fetch_poll(struct account *a, struct iolist *iol, struct io *pio, int timeout) struct io *rio; char *cause; double tim; + int dur; - log_debug3( - "%s: polling: %u, timeout=%d", a->name, ARRAY_LENGTH(iol), timeout); tim = get_time(); + +restart: + log_debug3("%s: polling: %u, timeout=%d, wake=%d", a->name, + ARRAY_LENGTH(iol), timeout, a->wakein); switch (io_polln( ARRAY_DATA(iol), ARRAY_LENGTH(iol), &rio, timeout, &cause)) { case 0: @@ -154,7 +158,12 @@ fetch_poll(struct account *a, struct iolist *iol, struct io *pio, int timeout) xfree(cause); return (-1); } - tim = get_time() - tim; + dur = (int)floor(get_time() - tim); + if (a->wakein && (a->wakein > dur)) { /* poll returned early, sleep. */ + sleep(a->wakein - dur); + timeout = a->wakein = 0; + goto restart; + } return (0); } @@ -360,7 +369,7 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) ARRAY_INIT(&iol); - aborted = complete = holding = 0; + aborted = complete = holding = a->wakein = 0; for (;;) { log_debug3("%s: fetch loop start", a->name); @@ -426,11 +435,10 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) /* Fetch again - no blocking. */ log_debug3("%s: fetch, again", a->name); continue; - case FETCH_RESTART: - log_debug("%s: sleeping",a->name); - sleep(conf.fetch_freq); - log_debug("%s: fetch, restart",a->name); - continue; + case FETCH_WAIT: + log_debug("%s: fetch, restart (%u secs)", + a->name,a->wakein); + break; case FETCH_BLOCK: /* Fetch again - allow blocking. */ log_debug3("%s: fetch, block", a->name); @@ -464,7 +472,11 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) * non-empty, we can block unless there are mails that aren't * blocked (these mails can continue to be processed). */ - timeout = conf.timeout; + + if (a->wakein) + timeout = a->wakein; + else + timeout = conf.timeout; if (fetch_queued == 0 && ARRAY_LENGTH(&iol) == 1) timeout = 0; else if (fetch_queued != 0 && fetch_blocked != fetch_queued) @@ -511,7 +523,7 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) /* In daemon mode, always try to restart. */ if (conf.daemon) { - sleep(conf.fetch_freq); + log_debug("%s: restarting", a->name); goto restart; } else return (aborted); diff --git a/fdm.h b/fdm.h index 7fa6a803..e8ce03c0 100644 --- a/fdm.h +++ b/fdm.h @@ -490,6 +490,7 @@ struct account { int disabled; int keep; + int wakein; /* secs */ int timeout; struct fetch *fetch; diff --git a/fetch.h b/fetch.h index 07922ae1..98fe386b 100644 --- a/fetch.h +++ b/fetch.h @@ -25,7 +25,7 @@ #define FETCH_ERROR 3 #define FETCH_MAIL 4 #define FETCH_EXIT 5 -#define FETCH_RESTART 6 +#define FETCH_WAIT 6 /* Fetch flags. */ #define FETCH_PURGE 0x1 diff --git a/imap-common.c b/imap-common.c index 6c8f629f..8ddbdb5c 100644 --- a/imap-common.c +++ b/imap-common.c @@ -1123,7 +1123,8 @@ imap_state_close(struct account *a, struct fetch_ctx *fctx) if (conf.daemon) { data->folder = 0; // go back to the first folder. fctx->state = imap_state_select1; - return (FETCH_RESTART); + a->wakein = conf.fetch_freq; + return (FETCH_WAIT); } if (imap_putln(a, "%u LOGOUT", ++data->tag) != 0) diff --git a/io.c b/io.c index 67f4e0a9..3639f34c 100644 --- a/io.c +++ b/io.c @@ -158,7 +158,7 @@ io_polln(struct io **iop, u_int n, struct io **rio, int timeout, char **cause) xfree(pfds); if (error == 0) { - if (timeout == 0) { + if (timeout != conf.timeout) { errno = EAGAIN; return (-1); } From 6df66e0af1a74d6b86f1094ad5fd390af0c3927b Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 31 Oct 2016 20:50:41 -0400 Subject: [PATCH 8/9] Bug fixes reset a->wakein more safely build fix (find math library and math.h) --- child-fetch.c | 16 ++++++++++------ configure.ac | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/child-fetch.c b/child-fetch.c index 4af5964d..870747ea 100644 --- a/child-fetch.c +++ b/child-fetch.c @@ -135,7 +135,7 @@ fetch_poll(struct account *a, struct iolist *iol, struct io *pio, int timeout) struct io *rio; char *cause; double tim; - int dur; + int remaining; tim = get_time(); @@ -158,11 +158,15 @@ fetch_poll(struct account *a, struct iolist *iol, struct io *pio, int timeout) xfree(cause); return (-1); } - dur = (int)floor(get_time() - tim); - if (a->wakein && (a->wakein > dur)) { /* poll returned early, sleep. */ - sleep(a->wakein - dur); - timeout = a->wakein = 0; - goto restart; + remaining = a->wakein - ((int)floor(get_time() - tim)); + if (a->wakein) { + a->wakein = 0; + if (remaining > 0) { + /* poll returned early, sleep. */ + sleep(remaining); + timeout = 0; + goto restart; + } } return (0); diff --git a/configure.ac b/configure.ac index 5793c2d5..e6ca5f41 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,7 @@ AC_CHECK_HEADERS( [ \ sys/queue.h \ sys/tree.h \ + math.h \ ] ) AC_CHECK_FUNCS( @@ -63,6 +64,10 @@ AC_CHECK_FUNCS( ] ) +AC_SEARCH_LIBS( + floor, + [m]) + AC_SEARCH_LIBS( tdb_open, [tdb], From fb3bee06432069b3bc633591fc12ea1d7607baad Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 1 Nov 2016 16:06:47 -0400 Subject: [PATCH 9/9] Continue sleeping through signals. Also combine FETCH_WAIT into FETCH_BLOCK in child_fetch.c --- child-fetch.c | 16 ++++++++-------- fetch.h | 1 - imap-common.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/child-fetch.c b/child-fetch.c index 870747ea..a8e1d2be 100644 --- a/child-fetch.c +++ b/child-fetch.c @@ -160,13 +160,12 @@ fetch_poll(struct account *a, struct iolist *iol, struct io *pio, int timeout) } remaining = a->wakein - ((int)floor(get_time() - tim)); if (a->wakein) { - a->wakein = 0; if (remaining > 0) { /* poll returned early, sleep. */ - sleep(remaining); - timeout = 0; + timeout = sleep(remaining); goto restart; } + a->wakein = 0; } return (0); @@ -439,13 +438,14 @@ fetch_account(struct account *a, struct io *pio, int nflags, double tim) /* Fetch again - no blocking. */ log_debug3("%s: fetch, again", a->name); continue; - case FETCH_WAIT: - log_debug("%s: fetch, restart (%u secs)", - a->name,a->wakein); - break; case FETCH_BLOCK: /* Fetch again - allow blocking. */ - log_debug3("%s: fetch, block", a->name); + if (a->wakein) + log_debug( + "%s: fetch, block (wake in %u secs)", + a->name,a->wakein); + else + log_debug3("%s: fetch, block", a->name); break; case FETCH_MAIL: /* Mail ready. */ diff --git a/fetch.h b/fetch.h index 98fe386b..7529eba9 100644 --- a/fetch.h +++ b/fetch.h @@ -25,7 +25,6 @@ #define FETCH_ERROR 3 #define FETCH_MAIL 4 #define FETCH_EXIT 5 -#define FETCH_WAIT 6 /* Fetch flags. */ #define FETCH_PURGE 0x1 diff --git a/imap-common.c b/imap-common.c index 8ddbdb5c..c9ab0b2b 100644 --- a/imap-common.c +++ b/imap-common.c @@ -1124,7 +1124,7 @@ imap_state_close(struct account *a, struct fetch_ctx *fctx) data->folder = 0; // go back to the first folder. fctx->state = imap_state_select1; a->wakein = conf.fetch_freq; - return (FETCH_WAIT); + return (FETCH_BLOCK); } if (imap_putln(a, "%u LOGOUT", ++data->tag) != 0)