From e2d498ab79e7211521ef80608803a8f2a8d4111c Mon Sep 17 00:00:00 2001 From: fredrik Date: Tue, 22 May 2007 00:41:18 +0000 Subject: [PATCH] Added cli.rescandelay. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1041 959494ce-11ee-0310-bf91-de5d638817bd --- daemon/client.c | 30 +++++++++++++++++++++++++++++- daemon/client.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/daemon/client.c b/daemon/client.c index c077453..e6075dc 100644 --- a/daemon/client.c +++ b/daemon/client.c @@ -103,7 +103,7 @@ static struct timer *hashwritetimer = NULL; * job. */ static pid_t hashjob = -1; struct sharecache *shareroot = NULL; -static time_t lastscan = 0; +static struct timer *scantimer = NULL; unsigned long long sharesize = 0; GCBCHAIN(sharechangecb, unsigned long long); @@ -973,6 +973,18 @@ int doscan(int quantum) return(1); } +static void rescancb(int cancelled, void *uudata) +{ + scantimer = NULL; + if(!cancelled) + { + if(scanqueue == NULL) + scanshares(); + else if(confgetint("cli", "rescandelay") > 0) + scantimer = timercallback(ntime() + confgetint("cli", "rescandelay"), (void (*)(int, void *))rescancb, NULL); + } +} + void scanshares(void) { struct sharepoint *cur; @@ -1003,6 +1015,10 @@ void scanshares(void) } queuescan(node); } + if(scantimer != NULL) + canceltimer(scantimer); + if(confgetint("cli", "rescandelay") > 0) + scantimer = timercallback(ntime() + confgetint("cli", "rescandelay"), (void (*)(int, void *))rescancb, NULL); } static void preinit(int hup) @@ -1020,6 +1036,15 @@ static void preinit(int hup) } } +static int rsdelayupdate(struct configvar *var, void *uudata) +{ + if(scantimer != NULL) + canceltimer(scantimer); + if(confgetint("cli", "rescandelay") > 0) + scantimer = timercallback(ntime() + var->val.num, (void (*)(int, void *))rescancb, NULL); + return(0); +} + static int init(int hup) { struct sharepoint *cur, *next; @@ -1033,7 +1058,10 @@ static int init(int hup) } scanshares(); if(!hup) + { while(doscan(100)); + CBREG(confgetvar("cli", "rescandelay"), conf_update, rsdelayupdate, NULL, NULL); + } return(0); } diff --git a/daemon/client.h b/daemon/client.h index 669b2ea..66fcf09 100644 --- a/daemon/client.h +++ b/daemon/client.h @@ -90,6 +90,7 @@ struct hash *duphash(struct hash *hash); struct hash *parsehash(wchar_t *text); wchar_t *unparsehash(struct hash *hash); int hashcmp(struct hash *h1, struct hash *h2); +void scanshares(void); extern struct sharecache *shareroot; extern unsigned long long sharesize; -- 2.11.0