gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33316 - gnunet/src/peerstore


From: gnunet
Subject: [GNUnet-SVN] r33316 - gnunet/src/peerstore
Date: Sun, 18 May 2014 16:01:27 +0200

Author: otarabai
Date: 2014-05-18 16:01:27 +0200 (Sun, 18 May 2014)
New Revision: 33316

Modified:
   gnunet/src/peerstore/gnunet-service-peerstore.c
   gnunet/src/peerstore/peerstore_api.c
   gnunet/src/peerstore/plugin_peerstore_sqlite.c
   gnunet/src/peerstore/test_peerstore_api.c
Log:
peerstore: towards iterate functionality


Modified: gnunet/src/peerstore/gnunet-service-peerstore.c
===================================================================
--- gnunet/src/peerstore/gnunet-service-peerstore.c     2014-05-17 17:39:50 UTC 
(rev 33315)
+++ gnunet/src/peerstore/gnunet-service-peerstore.c     2014-05-18 14:01:27 UTC 
(rev 33316)
@@ -120,6 +120,7 @@
   struct GNUNET_PEERSTORE_Record *record;
   struct GNUNET_SERVER_TransmitContext *tc;
 
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received an iterate request from 
client.\n");
   record = PEERSTORE_parse_record_message(message);
   if(NULL == record)
   {

Modified: gnunet/src/peerstore/peerstore_api.c
===================================================================
--- gnunet/src/peerstore/peerstore_api.c        2014-05-17 17:39:50 UTC (rev 
33315)
+++ gnunet/src/peerstore/peerstore_api.c        2014-05-18 14:01:27 UTC (rev 
33316)
@@ -211,7 +211,7 @@
 {
   struct GNUNET_PEERSTORE_Handle *h = cls;
 
-  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Received an error notification from MQ 
of type: %d\n", error);
+  LOG(GNUNET_ERROR_TYPE_ERROR, "Received an error notification from MQ of 
type: %d\n", error);
   reconnect(h);
 }
 
@@ -342,7 +342,7 @@
   sc = h->store_head;
   if(NULL == sc)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Unexpected store response, this 
should not happen.\n");
+    LOG(GNUNET_ERROR_TYPE_ERROR, "Unexpected store response, this should not 
happen.\n");
     reconnect(h);
     return;
   }
@@ -389,13 +389,13 @@
 void
 GNUNET_PEERSTORE_store_cancel (struct GNUNET_PEERSTORE_StoreContext *sc)
 {
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
           "Canceling store request.\n");
   if(GNUNET_NO == sc->request_sent)
   {
     if(NULL != sc->ev)
     {
-      //GNUNET_MQ_discard(sc->ev); //FIXME: this should be 
GNUNET_MQ_send_cancel
+      GNUNET_MQ_send_cancel(sc->ev);
       sc->ev = NULL;
     }
     GNUNET_CONTAINER_DLL_remove(sc->h->store_head, sc->h->store_tail, sc);
@@ -476,11 +476,12 @@
   void *callback_cls;
   uint16_t msg_type;
   struct GNUNET_PEERSTORE_Record *record;
+  int continue_iter;
 
   ic = h->iterate_head;
   if(NULL == ic)
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Unexpected iteration response, this 
should not happen.\n");
+    LOG(GNUNET_ERROR_TYPE_ERROR, "Unexpected iteration response, this should 
not happen.\n");
     reconnect(h);
     return;
   }
@@ -498,19 +499,21 @@
   msg_type = ntohs(msg->type);
   if(GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE_END == msg_type)
   {
+    GNUNET_CONTAINER_DLL_remove(ic->h->iterate_head, ic->h->iterate_tail, ic);
+    GNUNET_free(ic);
     if(NULL != callback)
       callback(callback_cls, NULL, NULL);
-    GNUNET_CONTAINER_DLL_remove(ic->h->iterate_head, ic->h->iterate_tail, ic);
-    GNUNET_free(ic);
     return;
   }
   if(NULL != callback)
   {
     record = PEERSTORE_parse_record_message(msg);
     if(NULL == record)
-      callback(callback_cls, record, _("Received a malformed response from 
service."));
+      continue_iter = callback(callback_cls, record, _("Received a malformed 
response from service."));
     else
-      callback(callback_cls, record, NULL);
+      continue_iter = callback(callback_cls, record, NULL);
+    if(GNUNET_NO == continue_iter)
+      ic->callback = NULL;
   }
 
 }
@@ -524,6 +527,7 @@
 {
   struct GNUNET_PEERSTORE_IterateContext *ic = cls;
 
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Iterate request sent to service.\n");
   ic->request_sent = GNUNET_YES;
   ic->ev = NULL;
 }
@@ -537,11 +541,12 @@
 void
 GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic)
 {
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "User request cancel of iterate request.\n");
   if(GNUNET_NO == ic->request_sent)
   {
     if(NULL != ic->ev)
     {
-      //GNUNET_MQ_discard(ic->ev); //FIXME: this should be 
GNUNET_MQ_send_cancel
+      GNUNET_MQ_send_cancel(ic->ev);
       ic->ev = NULL;
     }
     GNUNET_CONTAINER_DLL_remove(ic->h->iterate_head, ic->h->iterate_tail, ic);
@@ -587,6 +592,8 @@
   ic->h = h;
   ic->request_sent = GNUNET_NO;
   GNUNET_CONTAINER_DLL_insert(h->iterate_head, h->iterate_tail, ic);
+  LOG(GNUNET_ERROR_TYPE_DEBUG,
+        "Sending an iterate request for sub system `%s'\n", sub_system);
   GNUNET_MQ_notify_sent(ev, &iterate_request_sent, ev);
   GNUNET_MQ_send(h->mq, ev);
   return ic;

Modified: gnunet/src/peerstore/plugin_peerstore_sqlite.c
===================================================================
--- gnunet/src/peerstore/plugin_peerstore_sqlite.c      2014-05-17 17:39:50 UTC 
(rev 33315)
+++ gnunet/src/peerstore/plugin_peerstore_sqlite.c      2014-05-18 14:01:27 UTC 
(rev 33316)
@@ -124,6 +124,7 @@
   int sret;
   struct GNUNET_PEERSTORE_Record *ret;
 
+  LOG(GNUNET_ERROR_TYPE_DEBUG, "Executing iterate request on sqlite db.\n");
   if(NULL == peer && NULL == key)
   {
     stmt = plugin->select_peerstoredata;
@@ -161,6 +162,7 @@
   }
   while (SQLITE_ROW == (sret = sqlite3_step (stmt)))
   {
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "Returning a matched record.\n");
     ret = GNUNET_new(struct GNUNET_PEERSTORE_Record);
     ret->sub_system = (char *)sqlite3_column_text(stmt, 0);
     ret->peer = (struct GNUNET_PeerIdentity *)sqlite3_column_blob(stmt, 1);

Modified: gnunet/src/peerstore/test_peerstore_api.c
===================================================================
--- gnunet/src/peerstore/test_peerstore_api.c   2014-05-17 17:39:50 UTC (rev 
33315)
+++ gnunet/src/peerstore/test_peerstore_api.c   2014-05-18 14:01:27 UTC (rev 
33316)
@@ -82,7 +82,6 @@
   struct GNUNET_PeerIdentity pid;
   char *val = "peerstore-test-value";
   size_t val_size = strlen(val);
-  struct GNUNET_PEERSTORE_StoreContext *sc;
 
   ok = 0;
   memset (&pid, 32, sizeof (pid));




reply via email to

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