aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/gnunet-service-peerstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerstore/gnunet-service-peerstore.c')
-rw-r--r--src/peerstore/gnunet-service-peerstore.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c
index c92e4d3f0..959d088f9 100644
--- a/src/peerstore/gnunet-service-peerstore.c
+++ b/src/peerstore/gnunet-service-peerstore.c
@@ -77,6 +77,8 @@ static unsigned int num_clients;
77static void 77static void
78do_shutdown () 78do_shutdown ()
79{ 79{
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Shutting down peerstore, bye.\n");
80 if (NULL != db_lib_name) 82 if (NULL != db_lib_name)
81 { 83 {
82 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db)); 84 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, db));
@@ -105,6 +107,8 @@ do_shutdown ()
105static void 107static void
106shutdown_task (void *cls) 108shutdown_task (void *cls)
107{ 109{
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
111 "Priming PEERSTORE for shutdown.\n");
108 in_shutdown = GNUNET_YES; 112 in_shutdown = GNUNET_YES;
109 if (0 == num_clients) /* Only when no connected clients. */ 113 if (0 == num_clients) /* Only when no connected clients. */
110 do_shutdown (); 114 do_shutdown ();
@@ -176,6 +180,8 @@ client_connect_cb (void *cls,
176 struct GNUNET_MQ_Handle *mq) 180 struct GNUNET_MQ_Handle *mq)
177{ 181{
178 num_clients++; 182 num_clients++;
183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
184 "A client connected (now %u)\n", num_clients);
179 return client; 185 return client;
180} 186}
181 187
@@ -195,7 +201,7 @@ client_disconnect_it (void *cls, const struct GNUNET_HashCode *key, void *value)
195 { 201 {
196 GNUNET_assert (GNUNET_YES == 202 GNUNET_assert (GNUNET_YES ==
197 GNUNET_CONTAINER_multihashmap_remove (watchers, key, value)); 203 GNUNET_CONTAINER_multihashmap_remove (watchers, key, value));
198 num_clients++; 204 num_clients++; /* Watchers do not count */
199 } 205 }
200 return GNUNET_OK; 206 return GNUNET_OK;
201} 207}
@@ -212,12 +218,14 @@ client_disconnect_cb (void *cls,
212 struct GNUNET_SERVICE_Client *client, 218 struct GNUNET_SERVICE_Client *client,
213 void *app_cls) 219 void *app_cls)
214{ 220{
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "A client disconnected, cleaning up.\n"); 221 num_clients--;
216 if (NULL != watchers) 222 if (NULL != watchers)
217 GNUNET_CONTAINER_multihashmap_iterate (watchers, 223 GNUNET_CONTAINER_multihashmap_iterate (watchers,
218 &client_disconnect_it, 224 &client_disconnect_it,
219 client); 225 client);
220 num_clients--; 226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
227 "A client disconnected (%u remaining).\n",
228 num_clients);
221 if ((0 == num_clients) && in_shutdown) 229 if ((0 == num_clients) && in_shutdown)
222 do_shutdown (); 230 do_shutdown ();
223} 231}
@@ -540,6 +548,7 @@ run (void *cls,
540 char *database; 548 char *database;
541 549
542 in_shutdown = GNUNET_NO; 550 in_shutdown = GNUNET_NO;
551 num_clients = 0;
543 cfg = c; 552 cfg = c;
544 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, 553 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
545 "peerstore", 554 "peerstore",