gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10425 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r10425 - gnunet/src/fs
Date: Tue, 23 Feb 2010 15:59:29 +0100

Author: grothoff
Date: 2010-02-23 15:59:29 +0100 (Tue, 23 Feb 2010)
New Revision: 10425

Modified:
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_test_lib_data.conf
   gnunet/src/fs/gnunet-service-fs.c
Log:
bugfixes, extra assertions

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-02-23 13:49:06 UTC (rev 10424)
+++ gnunet/src/fs/fs_download.c 2010-02-23 14:59:29 UTC (rev 10425)
@@ -608,6 +608,10 @@
       memset (sm, 0, sizeof (struct SearchMessage));
       sm->header.size = htons (sizeof (struct SearchMessage));
       sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
+      if (dc->pending->depth == dc->treedepth)
+       sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_DBLOCK);
+      else
+       sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_IBLOCK);
       sm->anonymity_level = htonl (dc->anonymity);
       sm->target = dc->target.hashPubKey;
       sm->query = dc->pending->chk.query;

Modified: gnunet/src/fs/fs_test_lib_data.conf
===================================================================
--- gnunet/src/fs/fs_test_lib_data.conf 2010-02-23 13:49:06 UTC (rev 10424)
+++ gnunet/src/fs/fs_test_lib_data.conf 2010-02-23 14:59:29 UTC (rev 10425)
@@ -46,7 +46,7 @@
 PORT = 43471
 HOSTNAME = localhost
 DEBUG = YES
-#PREFIX = valgrind --tool=memcheck --leak-check=yes
+PREFIX = valgrind --tool=memcheck --leak-check=yes
 #BINARY = /home/grothoff/bin/gnunet-service-fs
 #PREFIX = xterm -e gdb -x cmd --args 
 

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-02-23 13:49:06 UTC (rev 10424)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-02-23 14:59:29 UTC (rev 10425)
@@ -2174,6 +2174,7 @@
   uint32_t ttl_decrement;
   uint32_t type;
   double preference;
+  int have_ns;
 
   msize = ntohs(message->size);
   if (msize < sizeof (struct GetMessage))
@@ -2182,6 +2183,18 @@
       return GNUNET_SYSERR;
     }
   gm = (const struct GetMessage*) message;
+  type = ntohl (gm->type);
+  switch (type)
+    {
+    case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+      break;
+    default:
+      GNUNET_break_op (0);
+      return GNUNET_SYSERR;
+    }
   bm = ntohl (gm->hash_bitmap);
   bits = 0;
   while (bm > 0)
@@ -2249,11 +2262,12 @@
              (unsigned int) ntohl (gm->type),
              GNUNET_i2s (other));
 #endif
+  have_ns = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE));
   pr = GNUNET_malloc (sizeof (struct PendingRequest) + 
-                     (bm & 
GET_MESSAGE_BIT_SKS_NAMESPACE)?sizeof(GNUNET_HashCode):0);
-  if ((bm & GET_MESSAGE_BIT_SKS_NAMESPACE))
+                     (have_ns ? sizeof(GNUNET_HashCode) : 0));
+  if (have_ns)
     pr->namespace = (GNUNET_HashCode*) &pr[1];
-  pr->type = ntohl (gm->type);
+  pr->type = type;
   pr->mingle = ntohl (gm->filter_mutator);
   if (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE))
     memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode));
@@ -2354,7 +2368,6 @@
   cps->inc_preference += preference;
 
   /* process locally */
-  type = pr->type;
   if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK)
     type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */
   timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY,
@@ -2438,6 +2451,19 @@
       client_list = cl;
     }
   type = ntohl (sm->type);
+  switch (type)
+    {
+    case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
+    case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+      break;
+    default:
+      GNUNET_break (0);
+      GNUNET_SERVER_receive_done (client,
+                                 GNUNET_SYSERR);
+      return GNUNET_SYSERR;
+    }  
 #if DEBUG_FS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Received request for `%s' of type %u from local client\n",





reply via email to

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