mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Rewritten queue() using xs_glob().
This commit is contained in:
parent
abca46d037
commit
a62cde3d9d
32
data.c
32
data.c
@ -978,31 +978,27 @@ void enqueue_output(snac *snac, char *msg, char *actor, int retries)
|
|||||||
d_char *queue(snac *snac)
|
d_char *queue(snac *snac)
|
||||||
/* returns a list with filenames that can be dequeued */
|
/* returns a list with filenames that can be dequeued */
|
||||||
{
|
{
|
||||||
xs *spec = xs_fmt("%s/queue/" "*.json", snac->basedir);
|
xs *spec = xs_fmt("%s/queue/" "*.json", snac->basedir);
|
||||||
d_char *list = xs_list_new();
|
d_char *list = xs_list_new();
|
||||||
glob_t globbuf;
|
time_t t = time(NULL);
|
||||||
time_t t = time(NULL);
|
char *p, *v;
|
||||||
|
|
||||||
if (glob(spec, 0, NULL, &globbuf) == 0) {
|
xs *fns = xs_glob(spec, 0, 0);
|
||||||
int n;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
for (n = 0; (p = globbuf.gl_pathv[n]) != NULL; n++) {
|
p = fns;
|
||||||
/* get the retry time from the basename */
|
while (xs_list_iter(&p, &v)) {
|
||||||
char *bn = strrchr(p, '/');
|
/* get the retry time from the basename */
|
||||||
time_t t2 = atol(bn + 1);
|
char *bn = strrchr(v, '/');
|
||||||
|
time_t t2 = atol(bn + 1);
|
||||||
|
|
||||||
if (t2 > t)
|
if (t2 > t)
|
||||||
snac_debug(snac, 2, xs_fmt("queue not yet time for %s", p));
|
snac_debug(snac, 2, xs_fmt("queue not yet time for %s", v));
|
||||||
else {
|
else {
|
||||||
list = xs_list_append(list, p);
|
list = xs_list_append(list, v);
|
||||||
snac_debug(snac, 2, xs_fmt("queue ready for %s", p));
|
snac_debug(snac, 2, xs_fmt("queue ready for %s", v));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globfree(&globbuf);
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user