diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-04-20 11:41:18 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-04-20 11:41:18 +0300 |
commit | ce2bded4521255e3a0f7d2926d4198e75743af1d (patch) | |
tree | b97924438f3309a172c0dd09aa1d1ba9e51819c6 /src/process.c | |
parent | 84838fa69592cf37f97aaa918ad4e69b8bd4d62a (diff) | |
download | wydawca-ce2bded4521255e3a0f7d2926d4198e75743af1d.tar.gz wydawca-ce2bded4521255e3a0f7d2926d4198e75743af1d.tar.bz2 |
Rewrite the timer support.
Timers are kept in a thread-specific array variable. Spool timers are
referenced in expansion strings by their fully qualified names, e.g.
${timer:spool:release:system}.
* NEWS: Update.
* doc/wydawca.texi: Document new syntax for the spool timer variables.
* src/directive.c
* src/wydawca.h (struct spool): New member: timer_id.
* tests/upload-dry.at: Filter out certain messages, that can appear
* src/process.c (spool_count): New global.
(register_spool): Build spool list in the same order as listed in the
configuration file.
(spool_timer_id): New function.
* src/timer.c: Rewrite using array of struct timer_slot, instead of the
hash table.
* src/triplet.c (try_timer_var): Rewrite.
* src/wydawca.c (stderr_printer): Protect stderr by a mutex.
in unpredictable order.
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c index beb0d72..323dbfe 100644 --- a/src/process.c +++ b/src/process.c @@ -21,14 +21,15 @@ struct spool_list { struct spool spool; }; -static struct spool_list *spool_list; +static struct spool_list *spool_head, *spool_tail; +size_t spool_count; int for_each_spool(int (*fun) (struct spool *, void *), void *data) { struct spool_list *sp; - for (sp = spool_list; sp; sp = sp->next) { + for (sp = spool_head; sp; sp = sp->next) { int rc = fun(&sp->spool, data); if (rc) return rc; @@ -41,8 +42,13 @@ register_spool(struct spool *spool) { struct spool_list *sp = grecs_malloc(sizeof *sp); sp->spool = *spool; - sp->next = spool_list; - spool_list = sp; + sp->next = NULL; + if (spool_tail) + spool_tail->next = sp; + else + spool_head = sp; + spool_tail = sp; + sp->spool.timer_id = spool_count++ + MY_TIMER_SPOOL_FIRST; } static int @@ -58,7 +64,7 @@ wydawca_find_spool(const char *name) { struct spool_list *sp; - for (sp = spool_list; sp; sp = sp->next) { + for (sp = spool_head; sp; sp = sp->next) { if (strcmp(sp->spool.tag, name) == 0 || spool_check_alias(&sp->spool, name)) return &sp->spool; @@ -183,9 +189,8 @@ scan_spool(struct spool *spool) return -1; } - timer_start("spool"); - /* FIXME: prefix spool tag with something */ - timer_start(spool->tag); + timer_start(WY_TIMER_SPOOL); + timer_start(spool->timer_id); while ((ent = readdir(dir))) { if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) @@ -195,8 +200,8 @@ scan_spool(struct spool *spool) closedir(dir); - timer_stop(spool->tag); - timer_stop("spool"); + timer_stop(spool->timer_id); + timer_stop(WY_TIMER_SPOOL); return 0; } @@ -231,7 +236,7 @@ void dictionaries_close(void) { struct spool_list *sp; - for (sp = spool_list; sp; sp = sp->next) + for (sp = spool_head; sp; sp = sp->next) spool_close_dictionaries(&sp->spool); } @@ -240,6 +245,19 @@ void scan_all_spools(void) { struct spool_list *sp; - for (sp = spool_list; sp; sp = sp->next) + for (sp = spool_head; sp; sp = sp->next) scan_spool(&sp->spool); } + +int +spool_timer_id(char *name) +{ + struct spool_list *sp; + for (sp = spool_head; sp; sp = sp->next) { + if (strcmp(sp->spool.tag, name) == 0) + return sp->spool.timer_id; + } + return -1; +} + + |