Browse Source

Notifies and shares should all be with the parent structure

master
Con Kolivas 10 years ago
parent
commit
af37739018
  1. 22
      src/generator.c

22
src/generator.c

@ -1990,9 +1990,9 @@ static void *userproxy_recv(void *arg)
} }
while (42) { while (42) {
proxy_instance_t *proxy, *parent;
share_msg_t *share, *tmpshare; share_msg_t *share, *tmpshare;
notify_instance_t *ni, *tmp; notify_instance_t *ni, *tmp;
proxy_instance_t *proxy;
connsock_t *cs; connsock_t *cs;
time_t now; time_t now;
int ret; int ret;
@ -2013,27 +2013,27 @@ static void *userproxy_recv(void *arg)
continue; continue;
} }
now = time(NULL); now = time(NULL);
parent = proxy->parent;
/* Age old notifications older than 10 mins old */ mutex_lock(&parent->notify_lock);
mutex_lock(&proxy->notify_lock); HASH_ITER(hh, parent->notify_instances, ni, tmp) {
HASH_ITER(hh, proxy->notify_instances, ni, tmp) { if (HASH_COUNT(parent->notify_instances) < 3)
if (HASH_COUNT(proxy->notify_instances) < 3)
break; break;
if (ni->notify_time < now - 600) { if (ni->notify_time < now - 600) {
HASH_DEL(proxy->notify_instances, ni); HASH_DEL(parent->notify_instances, ni);
clear_notify(ni); clear_notify(ni);
} }
} }
mutex_unlock(&proxy->notify_lock); mutex_unlock(&parent->notify_lock);
/* Similary with shares older than 2 mins without response */ /* Similary with shares older than 2 mins without response */
mutex_lock(&proxy->share_lock); mutex_lock(&parent->share_lock);
HASH_ITER(hh, proxy->shares, share, tmpshare) { HASH_ITER(hh, parent->shares, share, tmpshare) {
if (share->submit_time < now - 120) { if (share->submit_time < now - 120) {
HASH_DEL(proxy->shares, share); HASH_DEL(parent->shares, share);
} }
} }
mutex_unlock(&proxy->share_lock); mutex_unlock(&parent->share_lock);
do { do {
/* proxy may have been recycled here if it is not a /* proxy may have been recycled here if it is not a

Loading…
Cancel
Save