aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/gnunet-service-peerstore.c
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-06-03 17:17:42 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-06-03 17:17:42 +0000
commitf9cae638f0f5e6633868e14154dfd82421e5c39f (patch)
tree44c422718acd79510b0aed3741a2533a8a506179 /src/peerstore/gnunet-service-peerstore.c
parent1d644b000a0f0b5c12fe82a6c95d4874081b69a5 (diff)
minor fixes
Diffstat (limited to 'src/peerstore/gnunet-service-peerstore.c')
-rw-r--r--src/peerstore/gnunet-service-peerstore.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c
index febebc63a5..5d3ea6bb10 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -117,6 +117,22 @@ cleanup_expired_records(void *cls,
&cleanup_expired_records, NULL);
}
+/**
+ * Search for a disconnected client and remove it
+ *
+ * @param cls closuer, a 'struct GNUNET_PEERSTORE_Record *'
+ * @param key hash of record key
+ * @param value the watcher client, a 'struct GNUNET_SERVER_Client *'
+ * @return #GNUNET_YES to continue iterating
+ */
+int client_disconnect_it(void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ if(cls == value)
+ GNUNET_CONTAINER_multihashmap_remove(watchers, key, value);
+ return GNUNET_YES;
+}
/**
* A client disconnected. Remove all of its data structure entries.
@@ -129,6 +145,9 @@ handle_client_disconnect (void *cls,
struct GNUNET_SERVER_Client
* client)
{
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "A client was disconnected, cleaning up.\n");
+ GNUNET_CONTAINER_multihashmap_iterate(watchers,
+ &client_disconnect_it, client);
}
/**
@@ -177,9 +196,10 @@ int watch_notifier_it(void *cls,
struct StoreRecordMessage *srm;
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found a watcher to update.\n");
- if(NULL == value)
+ if(NULL == client)
{
- GNUNET_CONTAINER_multihashmap_remove(watchers, key, value);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing a dead client.\n");
+ GNUNET_CONTAINER_multihashmap_remove(watchers, key, client);
return GNUNET_YES;
}
srm = PEERSTORE_create_record_message(record->sub_system,