gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r8750 - gnunet/src/datastore
Date: Sun, 19 Jul 2009 05:31:54 -0600

Author: grothoff
Date: 2009-07-19 05:31:54 -0600 (Sun, 19 Jul 2009)
New Revision: 8750

Modified:
   gnunet/src/datastore/datastore.h
   gnunet/src/datastore/datastore_api.c
   gnunet/src/datastore/gnunet-service-datastore.c
   gnunet/src/datastore/plugin_datastore_sqlite.c
   gnunet/src/datastore/test_datastore_api.c
Log:
bugfixes

Modified: gnunet/src/datastore/datastore.h
===================================================================
--- gnunet/src/datastore/datastore.h    2009-07-19 09:10:43 UTC (rev 8749)
+++ gnunet/src/datastore/datastore.h    2009-07-19 11:31:54 UTC (rev 8750)
@@ -27,6 +27,8 @@
 #ifndef DATASTORE_H
 #define DATASTORE_H
 
+#define DEBUG_DATASTORE GNUNET_YES
+
 #include "gnunet_util_lib.h"
 
 /**

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2009-07-19 09:10:43 UTC (rev 
8749)
+++ gnunet/src/datastore/datastore_api.c        2009-07-19 11:31:54 UTC (rev 
8750)
@@ -215,7 +215,7 @@
        }
     }  
   h->response_proc = NULL;
-#if VERBOSE
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received status %d/%s\n",
              status,
@@ -255,12 +255,13 @@
            gettext_noop ("Error transmitting message to datastore 
service.\n"));
       return 0;
     }
-  GNUNET_assert (h->message_size <= size);
-  memcpy (buf, &h[1], h->message_size);
-#if VERBOSE
+  msize = h->message_size;
+  GNUNET_assert (msize <= size);
+  memcpy (buf, &h[1], msize);
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmitted %u byte message to datastore service, now waiting 
for status.\n",
-             h->message_size);
+             msize);
 #endif
   h->message_size = 0;
   GNUNET_CLIENT_receive (h->client,
@@ -295,7 +296,7 @@
 
   hdr = (const struct GNUNET_MessageHeader*) &h[1];
   msize = ntohs(hdr->size);
-#if VERBOSE
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmitting %u byte message of type %u to datastore service\n",
              msize,
@@ -356,6 +357,11 @@
   struct DataMessage *dm;
   size_t msize;
 
+#if DEBUG_DATASTORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Asked to put %u bytes of data\n",
+             size);
+#endif
   msize = sizeof(struct DataMessage) + size;
   GNUNET_assert (msize <= GNUNET_SERVER_MAX_MESSAGE_SIZE);
   dm = (struct DataMessage*) &h[1];
@@ -502,7 +508,7 @@
     {
       GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
       h->response_proc = NULL;
-#if VERBOSE
+#if DEBUG_DATASTORE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Received end of result set\n");
 #endif
@@ -533,7 +539,7 @@
            NULL, 0, NULL, 0, 0, 0, zero, 0);
       return;
     }
-#if VERBOSE
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received result %llu with type %u and size %u with key %s\n",
              (unsigned long long) GNUNET_ntohll(dm->uid),
@@ -585,12 +591,13 @@
            gettext_noop ("Error transmitting message to datastore 
service.\n"));
       return 0;
     }
-  GNUNET_assert (h->message_size <= size);
-  memcpy (buf, &h[1], h->message_size);
-#if VERBOSE
+  msize = h->message_size;
+  GNUNET_assert (msize <= size);
+  memcpy (buf, &h[1], msize);
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmitted %u byte message to datastore service, now waiting 
for result.\n",
-             h->message_size);
+             msize);
 #endif
   h->message_size = 0;
   GNUNET_CLIENT_receive (h->client,
@@ -626,7 +633,7 @@
 
   hdr = (const struct GNUNET_MessageHeader*) &h[1];
   msize = ntohs(hdr->size);
-#if VERBOSE
+#if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmitting %u byte message of type %u to datastore service\n",
              msize,

Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c     2009-07-19 09:10:43 UTC 
(rev 8749)
+++ gnunet/src/datastore/gnunet-service-datastore.c     2009-07-19 11:31:54 UTC 
(rev 8750)
@@ -38,8 +38,6 @@
 #include "plugin_datastore.h"
 #include "datastore.h"
 
-#define DEBUG_DATASTORE GNUNET_YES
-
 /**
  * How many messages do we queue at most per client?
  */
@@ -207,10 +205,6 @@
        tcc->tc (tcc->tc_cls, GNUNET_SYSERR);
       if (GNUNET_YES == tcc->end)
        {
-#if DEBUG_DATASTORE
-         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                     "Disconnecting client.\n");
-#endif 
          GNUNET_SERVER_receive_done (tcc->client, GNUNET_SYSERR);
        }
       GNUNET_free (tcc->msg);
@@ -308,10 +302,10 @@
 
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Transmitting `s' message with value %d and message %s\n",
+             "Transmitting `%s' message with value %d and message %s\n",
              "STATUS",
              code,
-             msg);
+             msg != NULL ? msg : "(none)");
 #endif
   slen = (msg == NULL) ? 0 : strlen(msg) + 1;  
   sm = GNUNET_malloc (sizeof(struct StatusMessage) + slen);
@@ -578,7 +572,7 @@
     GNUNET_CONTAINER_bloomfilter_add (filter,
                                      &dm->key);
   transmit_status (client, 
-                  GNUNET_SYSERR == ret ? GNUNET_SYSERR : GNUNET_OK, 
+                  (GNUNET_SYSERR == ret) ? GNUNET_SYSERR : GNUNET_OK, 
                   msg);
   GNUNET_free_non_null (msg);
 }
@@ -619,11 +613,16 @@
                                                         &msg->key)) )
     {
       /* don't bother database... */
+#if DEBUG_DATASTORE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Empty result set for `%s' request.\n",
+                 "GET");
+#endif 
       transmit_item (client,
                     NULL, NULL, 0, NULL, 0, 0, 0, zero, 0);
       return;
     }
-  GNUNET_SERVER_client_drop (client);
+  GNUNET_SERVER_client_keep (client);
   plugin->api->get (plugin->api->cls,
                    ((size == sizeof(struct GetMessage)) ? &msg->key : NULL),
                    NULL,
@@ -683,7 +682,7 @@
              "Processing `%s' request\n",
              "GET_RANDOM");
 #endif
-  GNUNET_SERVER_client_drop (client); // FIXME: WTF?
+  GNUNET_SERVER_client_keep (client);
   plugin->api->iter_migration_order (plugin->api->cls,
                                     0,
                                     &transmit_item,
@@ -725,8 +724,14 @@
                 expiration, uint64_t uid)
 {
   struct RemoveContext *rc = cls;
+
   if (key == NULL)
     {
+#if DEBUG_DATASTORE
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "No further matches for `%s' request.\n",
+                 "REMOVE");
+#endif 
       if (GNUNET_YES == rc->found)
        transmit_status (rc->client, GNUNET_OK, NULL);       
       else
@@ -736,9 +741,15 @@
       return GNUNET_OK; /* last item */
     }
   rc->found = GNUNET_YES;
-  plugin->api->next_request (next_cls, GNUNET_YES);
+#if DEBUG_DATASTORE
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Item %llu matches `%s' request.\n",
+             (unsigned long long) uid,
+             "REMOVE");
+#endif 
   GNUNET_CONTAINER_bloomfilter_remove (filter,
                                       key);
+  plugin->api->next_request (next_cls, GNUNET_YES);
   return GNUNET_NO;
 }
 
@@ -776,6 +787,7 @@
   GNUNET_CRYPTO_hash (&dm[1],
                      ntohl(dm->size),
                      &vhash);
+  GNUNET_SERVER_client_keep (client);
   plugin->api->get (plugin->api->cls,
                    &dm->key,
                    &vhash,
@@ -857,7 +869,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               _("Loading `%s' datastore plugin\n"), name);
   GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
-  ret->short_name = GNUNET_strdup (name);
+  ret->short_name = name;
   ret->lib_name = libname;
   ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
   if (ret->api == NULL)

Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c      2009-07-19 09:10:43 UTC 
(rev 8749)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c      2009-07-19 11:31:54 UTC 
(rev 8750)
@@ -29,7 +29,7 @@
 #include "plugin_datastore.h"
 #include <sqlite3.h>
 
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
 
 /**
  * After how many payload-changing operations
@@ -39,15 +39,7 @@
 
 #define QUOTA_STAT_NAME gettext_noop ("file-sharing datastore utilization (in 
bytes)")
 
-
 /**
- * Die with an error message that indicates
- * a failure of the command 'cmd' with the message given
- * by strerror(errno).
- */
-#define DIE_SQLITE(db, cmd) do { GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, 
"sqlite", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, 
sqlite3_errmsg(db->dbh)); abort(); } while(0)
-
-/**
  * Log an error message at log-level 'level' that indicates
  * a failure of the command 'cmd' on file 'filename'
  * with the message given by strerror(errno).

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2009-07-19 09:10:43 UTC (rev 
8749)
+++ gnunet/src/datastore/test_datastore_api.c   2009-07-19 11:31:54 UTC (rev 
8750)
@@ -68,7 +68,7 @@
 static int
 get_type(int i)
 {
-  return i;
+  return i+1;
 }
 
 





reply via email to

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