gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r13184 - in gnunet/src: datacache datastore dht include


From: gnunet
Subject: [GNUnet-SVN] r13184 - in gnunet/src: datacache datastore dht include
Date: Wed, 6 Oct 2010 13:44:29 +0200

Author: grothoff
Date: 2010-10-06 13:44:29 +0200 (Wed, 06 Oct 2010)
New Revision: 13184

Modified:
   gnunet/src/datacache/datacache.c
   gnunet/src/datacache/perf_datacache.c
   gnunet/src/datacache/plugin_datacache.h
   gnunet/src/datacache/plugin_datacache_mysql.c
   gnunet/src/datacache/plugin_datacache_postgres.c
   gnunet/src/datacache/plugin_datacache_sqlite.c
   gnunet/src/datacache/plugin_datacache_template.c
   gnunet/src/datacache/test_datacache.c
   gnunet/src/datastore/datastore_api.c
   gnunet/src/datastore/perf_datastore_api.c
   gnunet/src/datastore/test_datastore_api.c
   gnunet/src/datastore/test_datastore_api_management.c
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/include/gnunet_datacache_lib.h
   gnunet/src/include/gnunet_datastore_service.h
Log:
use size_t

Modified: gnunet/src/datacache/datacache.c
===================================================================
--- gnunet/src/datacache/datacache.c    2010-10-06 11:43:44 UTC (rev 13183)
+++ gnunet/src/datacache/datacache.c    2010-10-06 11:44:29 UTC (rev 13184)
@@ -100,7 +100,7 @@
 static void 
 env_delete_notify (void *cls,
                   const GNUNET_HashCode *key,
-                  uint32_t size)
+                  size_t size)
 {
   struct GNUNET_DATACACHE_Handle * h = cls;
   GNUNET_assert (h->utilization >= size);
@@ -237,7 +237,7 @@
 int 
 GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
                      const GNUNET_HashCode * key,
-                     uint32_t size,
+                     size_t size,
                      const char *data,
                      enum GNUNET_BLOCK_Type type,
                      struct GNUNET_TIME_Absolute discard_time)

Modified: gnunet/src/datacache/perf_datacache.c
===================================================================
--- gnunet/src/datacache/perf_datacache.c       2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datacache/perf_datacache.c       2010-10-06 11:44:29 UTC (rev 
13184)
@@ -46,7 +46,7 @@
 checkIt (void *cls,
         struct GNUNET_TIME_Absolute exp,
         const GNUNET_HashCode * key,
-         uint32_t size, 
+         size_t size, 
         const char *data, 
         enum GNUNET_BLOCK_Type type)
 {

Modified: gnunet/src/datacache/plugin_datacache.h
===================================================================
--- gnunet/src/datacache/plugin_datacache.h     2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datacache/plugin_datacache.h     2010-10-06 11:44:29 UTC (rev 
13184)
@@ -47,7 +47,7 @@
  */
 typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
                                                      const GNUNET_HashCode 
*key,
-                                                     uint32_t size);
+                                                     size_t size);
 
 
 /**
@@ -112,12 +112,12 @@
    * @param discard_time when to discard the value in any case
    * @return 0 on error, number of bytes used otherwise
    */
-  uint32_t (*put) (void *cls,
-                  const GNUNET_HashCode * key,
-                  uint32_t size,
-                  const char *data,
-                  enum GNUNET_BLOCK_Type type,
-                  struct GNUNET_TIME_Absolute discard_time);
+  size_t (*put) (void *cls,
+                const GNUNET_HashCode * key,
+                size_t size,
+                const char *data,
+                enum GNUNET_BLOCK_Type type,
+                struct GNUNET_TIME_Absolute discard_time);
 
 
   /**

Modified: gnunet/src/datacache/plugin_datacache_mysql.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_mysql.c       2010-10-06 11:43:44 UTC 
(rev 13183)
+++ gnunet/src/datacache/plugin_datacache_mysql.c       2010-10-06 11:44:29 UTC 
(rev 13184)
@@ -721,10 +721,10 @@
  * @param discard_time when to discard the value in any case
  * @return 0 on error, number of bytes used otherwise
  */
-static uint32_t 
+static size_t 
 mysql_plugin_put (void *cls,
                  const GNUNET_HashCode * key,
-                 uint32_t size,
+                 size_t size,
                  const char *data,
                  enum GNUNET_BLOCK_Type type,
                  struct GNUNET_TIME_Absolute discard_time)

Modified: gnunet/src/datacache/plugin_datacache_postgres.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_postgres.c    2010-10-06 11:43:44 UTC 
(rev 13183)
+++ gnunet/src/datacache/plugin_datacache_postgres.c    2010-10-06 11:44:29 UTC 
(rev 13184)
@@ -301,10 +301,10 @@
  * @param discard_time when to discard the value in any case
  * @return 0 on error, number of bytes used otherwise
  */
-static uint32_t 
+static size_t 
 postgres_plugin_put (void *cls,
                     const GNUNET_HashCode * key,
-                    uint32_t size,
+                    size_t size,
                     const char *data,
                     enum GNUNET_BLOCK_Type type,
                     struct GNUNET_TIME_Absolute discard_time)

Modified: gnunet/src/datacache/plugin_datacache_sqlite.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_sqlite.c      2010-10-06 11:43:44 UTC 
(rev 13183)
+++ gnunet/src/datacache/plugin_datacache_sqlite.c      2010-10-06 11:44:29 UTC 
(rev 13184)
@@ -94,10 +94,10 @@
  * @param discard_time when to discard the value in any case
  * @return 0 on error, number of bytes used otherwise
  */
-static uint32_t 
+static size_t 
 sqlite_plugin_put (void *cls,
                   const GNUNET_HashCode * key,
-                  uint32_t size,
+                  size_t size,
                   const char *data,
                   enum GNUNET_BLOCK_Type type,
                   struct GNUNET_TIME_Absolute discard_time)

Modified: gnunet/src/datacache/plugin_datacache_template.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_template.c    2010-10-06 11:43:44 UTC 
(rev 13183)
+++ gnunet/src/datacache/plugin_datacache_template.c    2010-10-06 11:44:29 UTC 
(rev 13184)
@@ -51,10 +51,10 @@
  * @param discard_time when to discard the value in any case
  * @return 0 on error, number of bytes used otherwise
  */
-static uint32_t 
+static size_t 
 template_plugin_put (void *cls,
                     const GNUNET_HashCode * key,
-                    uint32_t size,
+                    size_t size,
                     const char *data,
                     enum GNUNET_BLOCK_Type type,
                     struct GNUNET_TIME_Absolute discard_time)

Modified: gnunet/src/datacache/test_datacache.c
===================================================================
--- gnunet/src/datacache/test_datacache.c       2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datacache/test_datacache.c       2010-10-06 11:44:29 UTC (rev 
13184)
@@ -42,7 +42,7 @@
 checkIt (void *cls,
         struct GNUNET_TIME_Absolute exp,
         const GNUNET_HashCode * key,
-         uint32_t size, 
+         size_t size, 
         const char *data, 
         enum GNUNET_BLOCK_Type type)
 {

Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c        2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datastore/datastore_api.c        2010-10-06 11:44:29 UTC (rev 
13184)
@@ -765,7 +765,7 @@
 GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
                      int rid,
                       const GNUNET_HashCode * key,
-                      uint32_t size,
+                      size_t size,
                       const void *data,
                       enum GNUNET_BLOCK_Type type,
                       uint32_t priority,
@@ -801,7 +801,7 @@
   dm->header.type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_PUT);
   dm->header.size = htons(msize);
   dm->rid = htonl(rid);
-  dm->size = htonl(size);
+  dm->size = htonl( (uint32_t) size);
   dm->type = htonl(type);
   dm->priority = htonl(priority);
   dm->anonymity = htonl(anonymity);
@@ -1012,7 +1012,7 @@
 struct GNUNET_DATASTORE_QueueEntry *
 GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
                          const GNUNET_HashCode *key,
-                         uint32_t size, 
+                         size_t size, 
                         const void *data,
                         unsigned int queue_priority,
                         unsigned int max_queue_size,

Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c   2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datastore/perf_datastore_api.c   2010-10-06 11:44:29 UTC (rev 
13184)
@@ -101,7 +101,7 @@
   int i;
 
   GNUNET_HashCode key;
-  uint32_t esize;
+  size_t esize;
   char data[65536];
 };
 
@@ -197,7 +197,7 @@
 static void 
 delete_value (void *cls,
              const GNUNET_HashCode * key,
-             uint32_t size,
+             size_t size,
              const void *data,
              enum GNUNET_BLOCK_Type type,
              uint32_t priority,

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/datastore/test_datastore_api.c   2010-10-06 11:44:29 UTC (rev 
13184)
@@ -183,7 +183,7 @@
 static void 
 check_value (void *cls,
             const GNUNET_HashCode * key,
-            uint32_t size,
+            size_t size,
             const void *data,
             enum GNUNET_BLOCK_Type type,
             uint32_t priority,
@@ -221,7 +221,7 @@
 static void 
 delete_value (void *cls,
              const GNUNET_HashCode * key,
-             uint32_t size,
+             size_t size,
              const void *data,
              enum GNUNET_BLOCK_Type type,
              uint32_t priority,
@@ -261,7 +261,7 @@
 static void 
 check_nothing (void *cls,
               const GNUNET_HashCode * key,
-              uint32_t size,
+              size_t size,
               const void *data,
               enum GNUNET_BLOCK_Type type,
               uint32_t priority,
@@ -285,7 +285,7 @@
 static void 
 check_multiple (void *cls,
                const GNUNET_HashCode * key,
-               uint32_t size,
+               size_t size,
                const void *data,
                enum GNUNET_BLOCK_Type type,
                uint32_t priority,
@@ -343,7 +343,7 @@
 static void 
 check_update (void *cls,
              const GNUNET_HashCode * key,
-             uint32_t size,
+             size_t size,
              const void *data,
              enum GNUNET_BLOCK_Type type,
              uint32_t priority,

Modified: gnunet/src/datastore/test_datastore_api_management.c
===================================================================
--- gnunet/src/datastore/test_datastore_api_management.c        2010-10-06 
11:43:44 UTC (rev 13183)
+++ gnunet/src/datastore/test_datastore_api_management.c        2010-10-06 
11:44:29 UTC (rev 13184)
@@ -143,7 +143,7 @@
 static void 
 check_value (void *cls,
             const GNUNET_HashCode * key,
-            uint32_t size,
+            size_t size,
             const void *data,
             enum GNUNET_BLOCK_Type type,
             uint32_t priority,
@@ -191,7 +191,7 @@
 static void 
 check_nothing (void *cls,
               const GNUNET_HashCode * key,
-              uint32_t size,
+              size_t size,
               const void *data,
               enum GNUNET_BLOCK_Type type,
               uint32_t priority,

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-10-06 11:43:44 UTC (rev 13183)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-10-06 11:44:29 UTC (rev 13184)
@@ -2140,7 +2140,7 @@
 datacache_get_iterator (void *cls,
                         struct GNUNET_TIME_Absolute exp,
                         const GNUNET_HashCode * key,
-                        uint32_t size, const char *data, 
+                        size_t size, const char *data, 
                        enum GNUNET_BLOCK_Type type)
 {
   struct DHT_MessageContext *msg_ctx = cls;
@@ -2584,24 +2584,50 @@
                const struct GNUNET_MessageHeader *msg,
                 struct DHT_MessageContext *message_context)
 {
-  struct GNUNET_DHT_PutMessage *put_msg;
+  const struct GNUNET_DHT_PutMessage *put_msg;
   enum GNUNET_BLOCK_Type put_type;
   size_t data_size;
   int ret;
   struct RepublishContext *put_context;
+  GNUNET_HashCode key;
 
   GNUNET_assert (ntohs (msg->size) >=
                  sizeof (struct GNUNET_DHT_PutMessage));
 
 
-  put_msg = (struct GNUNET_DHT_PutMessage *)msg;
+  put_msg = (const struct GNUNET_DHT_PutMessage *)msg;
   put_type = (enum GNUNET_BLOCK_Type) ntohl (put_msg->type);
 
   if (put_type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE)
     return;
-
   data_size = ntohs (put_msg->header.size) - sizeof (struct 
GNUNET_DHT_PutMessage);
-
+  ret = GNUNET_BLOCK_get_key (block_context,
+                             put_type,
+                             &put_msg[1],
+                             data_size,
+                             &key);
+  if (GNUNET_NO == ret)
+    {
+      /* invalid reply */
+      GNUNET_break_op (0);
+      return;
+    }
+  if ( (GNUNET_YES == ret) &&
+       (0 != memcmp (&key,
+                    &message_context->key,
+                    sizeof (GNUNET_HashCode))) )
+    {
+      /* invalid wrapper: key mismatch! */
+      GNUNET_break_op (0);
+      return;
+    }
+  /* ret == GNUNET_SYSERR means that there is no known relationship between
+     data and the key, so we cannot check it */
+#if DEBUG_DHT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "`%s:%s': Received `%s' request (inserting data!), message type 
%d, key %s, uid %llu\n",
+              my_short_id, "DHT", "PUT", put_type, GNUNET_h2s 
(&message_context->key), message_context->unique_id);
+#endif
 #if DEBUG_DHT_ROUTING
   if (message_context->hop_count == 0) /* Locally initiated request */
     {
@@ -3655,7 +3681,7 @@
 republish_content_iterator (void *cls,
                             struct GNUNET_TIME_Absolute exp,
                             const GNUNET_HashCode * key,
-                            uint32_t size, const char *data, uint32_t type)
+                            size_t size, const char *data, uint32_t type)
 {
 
   struct DHT_MessageContext *new_msg_ctx;

Modified: gnunet/src/include/gnunet_datacache_lib.h
===================================================================
--- gnunet/src/include/gnunet_datacache_lib.h   2010-10-06 11:43:44 UTC (rev 
13183)
+++ gnunet/src/include/gnunet_datacache_lib.h   2010-10-06 11:44:29 UTC (rev 
13184)
@@ -85,7 +85,7 @@
 typedef int (*GNUNET_DATACACHE_Iterator) (void *cls,
                                          struct GNUNET_TIME_Absolute exp,
                                          const GNUNET_HashCode * key,
-                                         uint32_t size, /* FIXME: use size_t? 
*/
+                                         size_t size, 
                                          const char *data,
                                          enum GNUNET_BLOCK_Type type);
 
@@ -104,7 +104,7 @@
 int 
 GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
                      const GNUNET_HashCode * key,
-                     uint32_t size,
+                     size_t size,
                      const char *data,
                      enum GNUNET_BLOCK_Type type,
                      struct GNUNET_TIME_Absolute discard_time);

Modified: gnunet/src/include/gnunet_datastore_service.h
===================================================================
--- gnunet/src/include/gnunet_datastore_service.h       2010-10-06 11:43:44 UTC 
(rev 13183)
+++ gnunet/src/include/gnunet_datastore_service.h       2010-10-06 11:44:29 UTC 
(rev 13184)
@@ -153,7 +153,7 @@
 GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
                      int rid,
                       const GNUNET_HashCode * key,
-                      uint32_t size,
+                      size_t size,
                       const void *data,
                       enum GNUNET_BLOCK_Type type,
                       uint32_t priority,
@@ -250,7 +250,7 @@
 struct GNUNET_DATASTORE_QueueEntry *
 GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
                          const GNUNET_HashCode *key,
-                         uint32_t size, 
+                         size_t size, 
                         const void *data,
                         unsigned int queue_priority,
                         unsigned int max_queue_size,
@@ -275,7 +275,7 @@
  */
 typedef void (*GNUNET_DATASTORE_Iterator) (void *cls,
                                           const GNUNET_HashCode * key,
-                                          uint32_t size,
+                                          size_t size,
                                           const void *data,
                                           enum GNUNET_BLOCK_Type type,
                                           uint32_t priority,
@@ -353,6 +353,7 @@
                              GNUNET_DATASTORE_Iterator iter, 
                             void *iter_cls);
 
+
 /**
  * Cancel a datastore operation.  The final callback from the
  * operation must not have been done yet.




reply via email to

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