aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-14 15:11:10 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-14 15:11:10 +0000
commitdb482ed2af464d52e84ee20abe369ce9296afc72 (patch)
tree7d78b90df7b81d66ef47b2b197dbc874492254e8 /src/datastore
parent6aca87b77177bcfa6c9615563d2c00444a6432d3 (diff)
downloadgnunet-db482ed2af464d52e84ee20abe369ce9296afc72.tar.gz
gnunet-db482ed2af464d52e84ee20abe369ce9296afc72.zip
fixes
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 24f058556..7bdd3b38b 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -243,19 +243,32 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
243 struct GNUNET_DATASTORE_QueueEntry *qe; 243 struct GNUNET_DATASTORE_QueueEntry *qe;
244 244
245 if (h->client != NULL) 245 if (h->client != NULL)
246 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); 246 {
247 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
248 h->client = NULL;
249 }
247 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 250 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
248 GNUNET_SCHEDULER_cancel (h->sched, 251 {
249 h->reconnect_task); 252 GNUNET_SCHEDULER_cancel (h->sched,
250 h->client = NULL; 253 h->reconnect_task);
254 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
255 }
251 while (NULL != (qe = h->queue_head)) 256 while (NULL != (qe = h->queue_head))
252 { 257 {
253 GNUNET_CONTAINER_DLL_remove (h->queue_head,
254 h->queue_tail,
255 qe);
256 if (NULL != qe->response_proc) 258 if (NULL != qe->response_proc)
257 qe->response_proc (qe, NULL); 259 {
258 GNUNET_free (qe); 260 qe->response_proc (qe, NULL);
261 }
262 else
263 {
264 GNUNET_CONTAINER_DLL_remove (h->queue_head,
265 h->queue_tail,
266 qe);
267 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
268 GNUNET_SCHEDULER_cancel (h->sched,
269 qe->task);
270 GNUNET_free (qe);
271 }
259 } 272 }
260 if (GNUNET_YES == drop) 273 if (GNUNET_YES == drop)
261 { 274 {
@@ -435,6 +448,8 @@ try_reconnect (void *cls,
435static void 448static void
436do_disconnect (struct GNUNET_DATASTORE_Handle *h) 449do_disconnect (struct GNUNET_DATASTORE_Handle *h)
437{ 450{
451 if (h->client == NULL)
452 return;
438 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); 453 GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
439 h->client = NULL; 454 h->client = NULL;
440 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, 455 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched,
@@ -573,9 +588,17 @@ process_status_message (void *cls,
573 GNUNET_CONTAINER_DLL_remove (h->queue_head, 588 GNUNET_CONTAINER_DLL_remove (h->queue_head,
574 h->queue_tail, 589 h->queue_tail,
575 qe); 590 qe);
591 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
592 {
593 GNUNET_SCHEDULER_cancel (h->sched,
594 qe->task);
595 qe->task = GNUNET_SCHEDULER_NO_TASK;
596 }
576 GNUNET_free (qe); 597 GNUNET_free (qe);
577 if (msg == NULL) 598 if (msg == NULL)
578 { 599 {
600 if (NULL == h->client)
601 return; /* forced disconnect */
579 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 602 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
580 _("Failed to receive response from database.\n")); 603 _("Failed to receive response from database.\n"));
581 do_disconnect (h); 604 do_disconnect (h);