static pid_t hashjob = -1;
struct sharecache *shareroot = NULL;
static struct timer *scantimer = NULL;
+int sharedfiles = 0;
unsigned long long sharesize = 0;
GCBCHAIN(sharechangecb, unsigned long long);
*/
static void checkhashes(void)
{
- struct sharecache *node;
+ struct sharecache *node, *next;
struct hashcache *hc;
char *path;
node = shareroot->child;
- for(node = shareroot->child; node != NULL; node = nextscnode(node))
+ for(node = shareroot->child; node != NULL; node = next)
{
+ next = nextscnode(node);
if(node->f.b.type != FILE_REG)
continue;
if(!node->f.b.hastth)
CBCHAINDOCB(node, share_delete, node);
CBCHAINFREE(node, share_delete);
sharesize -= node->size;
+ if(node->f.b.type == FILE_REG)
+ sharedfiles--;
if(node->path != NULL)
free(node->path);
if(node->name != NULL)
if(S_ISREG(sb.st_mode))
{
sharesize += (n->size = sb.st_size);
+ sharedfiles++;
} else {
n->size = 0;
}
{
if(hashjob != 0)
kill(hashjob, SIGHUP);
+ if(hashwritetimer != NULL)
+ writehashcache(1);
while(shares != NULL)
freesharepoint(shares);
freecache(shareroot);