Abstract from update trigger mechanism:
(update_trigger): New. (force, zdon): Use it. (update_sem, update_force): Internal linkage. (update_trigger, update_force): Passing a pointer to static storage as thread argument is racy. Use dynamic allocation.
This commit is contained in:
parent
553662f305
commit
861112f827
4 changed files with 38 additions and 10 deletions
|
@ -34,13 +34,12 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "commands.h"
|
||||
#include "empthread.h"
|
||||
#include "server.h"
|
||||
|
||||
int
|
||||
force(void)
|
||||
{
|
||||
static int seconds;
|
||||
int seconds;
|
||||
|
||||
if (update_pending) {
|
||||
pr("Update is pending\n");
|
||||
|
@ -59,7 +58,7 @@ force(void)
|
|||
return RET_FAIL;
|
||||
|
||||
pr("Scheduling update in %d second(s)\n", seconds);
|
||||
empth_create(PP_SCHED, update_force, (50 * 1024), 0, "forceUpdate",
|
||||
"Schedules an update", &seconds);
|
||||
if (update_trigger(seconds) < 0)
|
||||
return RET_FAIL;
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "commands.h"
|
||||
#include "empthread.h"
|
||||
#include "optlist.h"
|
||||
#include "server.h"
|
||||
|
||||
|
@ -142,7 +141,7 @@ zdon(void)
|
|||
|
||||
if (!checking && wantupd && demandupdatecheck()) {
|
||||
pr("Here goes...\n");
|
||||
empth_sem_signal(update_sem);
|
||||
update_trigger(0);
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue