Skip to content

Commit

Permalink
Add fetch-frequency configuration option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Pomerantz committed Oct 27, 2016
1 parent 7ecfd72 commit 4c39749
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
19 changes: 9 additions & 10 deletions child-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
}

/*
Expand Down
1 change: 1 addition & 0 deletions fdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions fdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
5 changes: 5 additions & 0 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ yyerror(const char *fmt, ...)
%token TOKEXEC
%token TOKEXPIRE
%token TOKFCNTL
%token TOKFETCHFREQ
%token TOKFILEGROUP
%token TOKFILEUMASK
%token TOKFLOCK
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4c39749

Please sign in to comment.