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)
downloadgnunet-f9cae638f0f5e6633868e14154dfd82421e5c39f.tar.gz
gnunet-f9cae638f0f5e6633868e14154dfd82421e5c39f.zip
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 febebc63a..5d3ea6bb1 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -117,6 +117,22 @@ cleanup_expired_records(void *cls,
117 &cleanup_expired_records, NULL); 117 &cleanup_expired_records, NULL);
118} 118}
119 119
120/**
121 * Search for a disconnected client and remove it
122 *
123 * @param cls closuer, a 'struct GNUNET_PEERSTORE_Record *'
124 * @param key hash of record key
125 * @param value the watcher client, a 'struct GNUNET_SERVER_Client *'
126 * @return #GNUNET_YES to continue iterating
127 */
128int client_disconnect_it(void *cls,
129 const struct GNUNET_HashCode *key,
130 void *value)
131{
132 if(cls == value)
133 GNUNET_CONTAINER_multihashmap_remove(watchers, key, value);
134 return GNUNET_YES;
135}
120 136
121/** 137/**
122 * A client disconnected. Remove all of its data structure entries. 138 * A client disconnected. Remove all of its data structure entries.
@@ -129,6 +145,9 @@ handle_client_disconnect (void *cls,
129 struct GNUNET_SERVER_Client 145 struct GNUNET_SERVER_Client
130 * client) 146 * client)
131{ 147{
148 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "A client was disconnected, cleaning up.\n");
149 GNUNET_CONTAINER_multihashmap_iterate(watchers,
150 &client_disconnect_it, client);
132} 151}
133 152
134/** 153/**
@@ -177,9 +196,10 @@ int watch_notifier_it(void *cls,
177 struct StoreRecordMessage *srm; 196 struct StoreRecordMessage *srm;
178 197
179 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found a watcher to update.\n"); 198 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found a watcher to update.\n");
180 if(NULL == value) 199 if(NULL == client)
181 { 200 {
182 GNUNET_CONTAINER_multihashmap_remove(watchers, key, value); 201 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Removing a dead client.\n");
202 GNUNET_CONTAINER_multihashmap_remove(watchers, key, client);
183 return GNUNET_YES; 203 return GNUNET_YES;
184 } 204 }
185 srm = PEERSTORE_create_record_message(record->sub_system, 205 srm = PEERSTORE_create_record_message(record->sub_system,