gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r15362 - gnunet/src/datastore


From: gnunet
Subject: [GNUnet-SVN] r15362 - gnunet/src/datastore
Date: Tue, 31 May 2011 02:15:15 +0200

Author: grothoff
Date: 2011-05-31 02:15:15 +0200 (Tue, 31 May 2011)
New Revision: 15362

Modified:
   gnunet/src/datastore/datastore_api.c
Log:
nicer

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2011-05-30 23:16:24 UTC (rev 
15361)
+++ gnunet/src/datastore/datastore_api.c        2011-05-31 00:15:15 UTC (rev 
15362)
@@ -371,7 +371,6 @@
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_DATASTORE_QueueEntry *qe = cls;
-  int in_receive;
 
   GNUNET_STATISTICS_update (qe->h->stats,
                            gettext_noop ("# queue entry timeouts"),
@@ -379,9 +378,7 @@
                            GNUNET_NO);
   qe->task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (qe->was_transmitted == GNUNET_NO); 
-  in_receive = qe->h->in_receive;
   qe->response_proc (qe->h, NULL);
-  qe->h->in_receive = in_receive;
 }
 
 
@@ -411,7 +408,6 @@
   struct GNUNET_DATASTORE_QueueEntry *ret;
   struct GNUNET_DATASTORE_QueueEntry *pos;
   unsigned int c;
-  int in_receive;
 
   c = 0;
   pos = h->queue_head;
@@ -466,7 +462,6 @@
   ret->task = GNUNET_SCHEDULER_add_delayed (timeout,
                                            &timeout_queue_entry,
                                            ret);
-  in_receive = h->in_receive;
   pos = ret->next;
   while (pos != NULL) 
     {
@@ -491,7 +486,6 @@
        }
       pos = pos->next;
     }
-  h->in_receive = in_receive;
   return ret;
 }
 
@@ -577,6 +571,31 @@
 
 
 /**
+ * Function called whenever we receive a message from
+ * the service.  Calls the appropriate handler.
+ *
+ * @param cls the 'struct GNUNET_DATASTORE_Handle'
+ * @param msg the received message
+ */
+static void 
+receive_cb (void *cls,
+           const struct GNUNET_MessageHeader *msg)
+{
+  struct GNUNET_DATASTORE_Handle *h = cls;
+  struct GNUNET_DATASTORE_QueueEntry *qe;
+
+  h->in_receive = GNUNET_NO;
+  if (NULL == (qe = h->queue_head))
+    {
+      GNUNET_break (0);
+      process_queue (h);
+      return; 
+    }
+  qe->response_proc (h, msg);
+}
+
+
+/**
  * Transmit request from queue to datastore service.
  *
  * @param cls the 'struct GNUNET_DATASTORE_Handle'
@@ -624,7 +643,7 @@
   GNUNET_assert (GNUNET_NO == h->in_receive);
   h->in_receive = GNUNET_YES;
   GNUNET_CLIENT_receive (h->client,
-                        qe->response_proc,
+                        &receive_cb,
                         h,
                         GNUNET_TIME_absolute_get_remaining (qe->timeout));
   GNUNET_STATISTICS_update (h->stats,
@@ -759,7 +778,6 @@
   int32_t status;
   int was_transmitted;
 
-  h->in_receive = GNUNET_NO;
   if (h->skip_next_messages > 0)
     {
       h->skip_next_messages--;
@@ -1234,7 +1252,6 @@
   struct ResultContext rc;
   const struct DataMessage *dm;
 
-  h->in_receive = GNUNET_NO;
   if (h->skip_next_messages > 0)
     {
       h->skip_next_messages--;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]