bugfixes, extra assertions
authorChristian Grothoff <christian@grothoff.org>
Tue, 23 Feb 2010 14:59:29 +0000 (14:59 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 23 Feb 2010 14:59:29 +0000 (14:59 +0000)
src/fs/fs_download.c
src/fs/fs_test_lib_data.conf
src/fs/gnunet-service-fs.c

index 1399cf8dd7c1cbc1740af0efae77fd93498ca34e..aa78a929450d8301d492fd748e7271cd19fe0ed2 100644 (file)
@@ -608,6 +608,10 @@ transmit_download_request (void *cls,
       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;
index d62ee8c983b86b3db080ac3caaa9203b6cce9735..7ca0166a162d0fdc761b44cc08cbbdad09ce4ade 100644 (file)
@@ -46,7 +46,7 @@ DEBUG = YES
 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 
 
index 7ae9aaafa652f895c9c671b0446af78f2e452da1..efade85219a879c5573603de0cc21d4a2ad6d3ab 100644 (file)
@@ -2174,6 +2174,7 @@ handle_p2p_get (void *cls,
   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 @@ handle_p2p_get (void *cls,
       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 @@ handle_p2p_get (void *cls,
              (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 @@ handle_p2p_get (void *cls,
   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 @@ handle_start_search (void *cls,
       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",