aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-17 07:17:48 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-17 07:17:48 +0000
commitbe23aeefdd4f3732ede252f21445c30331788405 (patch)
treec6007cc818ea91e2466643efc80991fe5292f716 /src/datastore
parent0ca491e0f2b01276eaf51f6e7fad33099b58b182 (diff)
downloadgnunet-be23aeefdd4f3732ede252f21445c30331788405.tar.gz
gnunet-be23aeefdd4f3732ede252f21445c30331788405.zip
lc stuff
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c85
1 files changed, 29 insertions, 56 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 89c7edba3..16db19f94 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -255,20 +255,8 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
255 } 255 }
256 while (NULL != (qe = h->queue_head)) 256 while (NULL != (qe = h->queue_head))
257 { 257 {
258 if (NULL != qe->response_proc) 258 GNUNET_assert (NULL != qe->response_proc);
259 { 259 qe->response_proc (qe, NULL);
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 }
272 } 260 }
273 if (GNUNET_YES == drop) 261 if (GNUNET_YES == drop)
274 { 262 {
@@ -385,15 +373,8 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
385 { 373 {
386 if (pos->max_queue < h->queue_size) 374 if (pos->max_queue < h->queue_size)
387 { 375 {
388 GNUNET_CONTAINER_DLL_remove (h->queue_head, 376 GNUNET_assert (pos->response_proc != NULL);
389 h->queue_tail, 377 pos->response_proc (pos, NULL);
390 pos);
391 GNUNET_SCHEDULER_cancel (h->sched,
392 pos->task);
393 if (pos->response_proc != NULL)
394 pos->response_proc (pos, NULL);
395 GNUNET_free (pos);
396 h->queue_size--;
397 break; 378 break;
398 } 379 }
399 pos = pos->next; 380 pos = pos->next;
@@ -565,6 +546,24 @@ drop_status_cont (void *cls, int result, const char *emsg)
565} 546}
566 547
567 548
549static void
550free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe)
551{
552 struct GNUNET_DATASTORE_Handle *h = qe->h;
553
554 GNUNET_CONTAINER_DLL_remove (h->queue_head,
555 h->queue_tail,
556 qe);
557 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
558 {
559 GNUNET_SCHEDULER_cancel (h->sched,
560 qe->task);
561 qe->task = GNUNET_SCHEDULER_NO_TASK;
562 }
563 h->queue_size--;
564 GNUNET_free (qe);
565}
566
568/** 567/**
569 * Type of a function to call when we receive a message 568 * Type of a function to call when we receive a message
570 * from the service. 569 * from the service.
@@ -584,16 +583,7 @@ process_status_message (void *cls,
584 const char *emsg; 583 const char *emsg;
585 int32_t status; 584 int32_t status;
586 585
587 GNUNET_CONTAINER_DLL_remove (h->queue_head, 586 free_queue_entry (qe);
588 h->queue_tail,
589 qe);
590 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
591 {
592 GNUNET_SCHEDULER_cancel (h->sched,
593 qe->task);
594 qe->task = GNUNET_SCHEDULER_NO_TASK;
595 }
596 GNUNET_free (qe);
597 if (msg == NULL) 587 if (msg == NULL)
598 { 588 {
599 if (NULL == h->client) 589 if (NULL == h->client)
@@ -1018,10 +1008,7 @@ process_result_message (void *cls,
1018 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1008 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1019 _("Failed to receive response from datastore\n")); 1009 _("Failed to receive response from datastore\n"));
1020#endif 1010#endif
1021 GNUNET_CONTAINER_DLL_remove (h->queue_head, 1011 free_queue_entry (qe);
1022 h->queue_tail,
1023 qe);
1024 GNUNET_free (qe);
1025 do_disconnect (h); 1012 do_disconnect (h);
1026 rc->iter (rc->iter_cls, 1013 rc->iter (rc->iter_cls,
1027 NULL, 0, NULL, 0, 0, 0, 1014 NULL, 0, NULL, 0, 0, 0,
@@ -1036,10 +1023,7 @@ process_result_message (void *cls,
1036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1037 "Received end of result set\n"); 1024 "Received end of result set\n");
1038#endif 1025#endif
1039 GNUNET_CONTAINER_DLL_remove (h->queue_head, 1026 free_queue_entry (qe);
1040 h->queue_tail,
1041 qe);
1042 GNUNET_free (qe);
1043 rc->iter (rc->iter_cls, 1027 rc->iter (rc->iter_cls,
1044 NULL, 0, NULL, 0, 0, 0, 1028 NULL, 0, NULL, 0, 0, 0,
1045 GNUNET_TIME_UNIT_ZERO_ABS, 0); 1029 GNUNET_TIME_UNIT_ZERO_ABS, 0);
@@ -1052,10 +1036,7 @@ process_result_message (void *cls,
1052 (ntohs(msg->size) != sizeof(struct DataMessage) + ntohl (((const struct DataMessage*)msg)->size)) ) 1036 (ntohs(msg->size) != sizeof(struct DataMessage) + ntohl (((const struct DataMessage*)msg)->size)) )
1053 { 1037 {
1054 GNUNET_break (0); 1038 GNUNET_break (0);
1055 GNUNET_CONTAINER_DLL_remove (h->queue_head, 1039 free_queue_entry (qe);
1056 h->queue_tail,
1057 qe);
1058 GNUNET_free (qe);
1059 h->retry_time = GNUNET_TIME_UNIT_ZERO; 1040 h->retry_time = GNUNET_TIME_UNIT_ZERO;
1060 do_disconnect (h); 1041 do_disconnect (h);
1061 rc->iter (rc->iter_cls, 1042 rc->iter (rc->iter_cls,
@@ -1226,10 +1207,7 @@ GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h,
1226 GNUNET_TIME_absolute_get_remaining (qe->timeout)); 1207 GNUNET_TIME_absolute_get_remaining (qe->timeout));
1227 return; 1208 return;
1228 } 1209 }
1229 GNUNET_CONTAINER_DLL_remove (h->queue_head, 1210 free_queue_entry (qe);
1230 h->queue_tail,
1231 qe);
1232 GNUNET_free (qe);
1233 h->retry_time = GNUNET_TIME_UNIT_ZERO; 1211 h->retry_time = GNUNET_TIME_UNIT_ZERO;
1234 do_disconnect (h); 1212 do_disconnect (h);
1235 rc->iter (rc->iter_cls, 1213 rc->iter (rc->iter_cls,
@@ -1253,13 +1231,8 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe)
1253 1231
1254 h = qe->h; 1232 h = qe->h;
1255 reconnect = qe->was_transmitted; 1233 reconnect = qe->was_transmitted;
1256 GNUNET_CONTAINER_DLL_remove (h->queue_head, 1234 free_queue_entry (qe);
1257 h->queue_tail, 1235 h->queue_size--;
1258 qe);
1259 if (qe->task != GNUNET_SCHEDULER_NO_TASK)
1260 GNUNET_SCHEDULER_cancel (h->sched,
1261 qe->task);
1262 GNUNET_free (qe);
1263 if (reconnect) 1236 if (reconnect)
1264 { 1237 {
1265 h->retry_time = GNUNET_TIME_UNIT_ZERO; 1238 h->retry_time = GNUNET_TIME_UNIT_ZERO;