aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-05-31 00:15:15 +0000
committerChristian Grothoff <christian@grothoff.org>2011-05-31 00:15:15 +0000
commitf9e8f6651beac8e654a03fe5092c92076c52dc78 (patch)
tree5e89de0face4ab535cd2855fa22071effa5082c3 /src/datastore
parent9b22b5817ab723ff24a83146c86b325e71313f48 (diff)
downloadgnunet-f9e8f6651beac8e654a03fe5092c92076c52dc78.tar.gz
gnunet-f9e8f6651beac8e654a03fe5092c92076c52dc78.zip
nicer
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 6bf9abaca..624d0cad7 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -371,7 +371,6 @@ timeout_queue_entry (void *cls,
371 const struct GNUNET_SCHEDULER_TaskContext *tc) 371 const struct GNUNET_SCHEDULER_TaskContext *tc)
372{ 372{
373 struct GNUNET_DATASTORE_QueueEntry *qe = cls; 373 struct GNUNET_DATASTORE_QueueEntry *qe = cls;
374 int in_receive;
375 374
376 GNUNET_STATISTICS_update (qe->h->stats, 375 GNUNET_STATISTICS_update (qe->h->stats,
377 gettext_noop ("# queue entry timeouts"), 376 gettext_noop ("# queue entry timeouts"),
@@ -379,9 +378,7 @@ timeout_queue_entry (void *cls,
379 GNUNET_NO); 378 GNUNET_NO);
380 qe->task = GNUNET_SCHEDULER_NO_TASK; 379 qe->task = GNUNET_SCHEDULER_NO_TASK;
381 GNUNET_assert (qe->was_transmitted == GNUNET_NO); 380 GNUNET_assert (qe->was_transmitted == GNUNET_NO);
382 in_receive = qe->h->in_receive;
383 qe->response_proc (qe->h, NULL); 381 qe->response_proc (qe->h, NULL);
384 qe->h->in_receive = in_receive;
385} 382}
386 383
387 384
@@ -411,7 +408,6 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
411 struct GNUNET_DATASTORE_QueueEntry *ret; 408 struct GNUNET_DATASTORE_QueueEntry *ret;
412 struct GNUNET_DATASTORE_QueueEntry *pos; 409 struct GNUNET_DATASTORE_QueueEntry *pos;
413 unsigned int c; 410 unsigned int c;
414 int in_receive;
415 411
416 c = 0; 412 c = 0;
417 pos = h->queue_head; 413 pos = h->queue_head;
@@ -466,7 +462,6 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
466 ret->task = GNUNET_SCHEDULER_add_delayed (timeout, 462 ret->task = GNUNET_SCHEDULER_add_delayed (timeout,
467 &timeout_queue_entry, 463 &timeout_queue_entry,
468 ret); 464 ret);
469 in_receive = h->in_receive;
470 pos = ret->next; 465 pos = ret->next;
471 while (pos != NULL) 466 while (pos != NULL)
472 { 467 {
@@ -491,7 +486,6 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h,
491 } 486 }
492 pos = pos->next; 487 pos = pos->next;
493 } 488 }
494 h->in_receive = in_receive;
495 return ret; 489 return ret;
496} 490}
497 491
@@ -577,6 +571,31 @@ do_disconnect (struct GNUNET_DATASTORE_Handle *h)
577 571
578 572
579/** 573/**
574 * Function called whenever we receive a message from
575 * the service. Calls the appropriate handler.
576 *
577 * @param cls the 'struct GNUNET_DATASTORE_Handle'
578 * @param msg the received message
579 */
580static void
581receive_cb (void *cls,
582 const struct GNUNET_MessageHeader *msg)
583{
584 struct GNUNET_DATASTORE_Handle *h = cls;
585 struct GNUNET_DATASTORE_QueueEntry *qe;
586
587 h->in_receive = GNUNET_NO;
588 if (NULL == (qe = h->queue_head))
589 {
590 GNUNET_break (0);
591 process_queue (h);
592 return;
593 }
594 qe->response_proc (h, msg);
595}
596
597
598/**
580 * Transmit request from queue to datastore service. 599 * Transmit request from queue to datastore service.
581 * 600 *
582 * @param cls the 'struct GNUNET_DATASTORE_Handle' 601 * @param cls the 'struct GNUNET_DATASTORE_Handle'
@@ -624,7 +643,7 @@ transmit_request (void *cls,
624 GNUNET_assert (GNUNET_NO == h->in_receive); 643 GNUNET_assert (GNUNET_NO == h->in_receive);
625 h->in_receive = GNUNET_YES; 644 h->in_receive = GNUNET_YES;
626 GNUNET_CLIENT_receive (h->client, 645 GNUNET_CLIENT_receive (h->client,
627 qe->response_proc, 646 &receive_cb,
628 h, 647 h,
629 GNUNET_TIME_absolute_get_remaining (qe->timeout)); 648 GNUNET_TIME_absolute_get_remaining (qe->timeout));
630 GNUNET_STATISTICS_update (h->stats, 649 GNUNET_STATISTICS_update (h->stats,
@@ -759,7 +778,6 @@ process_status_message (void *cls,
759 int32_t status; 778 int32_t status;
760 int was_transmitted; 779 int was_transmitted;
761 780
762 h->in_receive = GNUNET_NO;
763 if (h->skip_next_messages > 0) 781 if (h->skip_next_messages > 0)
764 { 782 {
765 h->skip_next_messages--; 783 h->skip_next_messages--;
@@ -1234,7 +1252,6 @@ process_result_message (void *cls,
1234 struct ResultContext rc; 1252 struct ResultContext rc;
1235 const struct DataMessage *dm; 1253 const struct DataMessage *dm;
1236 1254
1237 h->in_receive = GNUNET_NO;
1238 if (h->skip_next_messages > 0) 1255 if (h->skip_next_messages > 0)
1239 { 1256 {
1240 h->skip_next_messages--; 1257 h->skip_next_messages--;