diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-23 14:59:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-23 14:59:29 +0000 |
commit | b6956204e275423100b333aeb25028118a682335 (patch) | |
tree | ee35e4d43cae25e487bd4e2de789ef036f890d21 | |
parent | 989554955ea8a1ea0932b52912eb916d91181582 (diff) | |
download | gnunet-b6956204e275423100b333aeb25028118a682335.tar.gz gnunet-b6956204e275423100b333aeb25028118a682335.zip |
bugfixes, extra assertions
-rw-r--r-- | src/fs/fs_download.c | 4 | ||||
-rw-r--r-- | src/fs/fs_test_lib_data.conf | 2 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 34 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 1399cf8dd..aa78a9294 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -608,6 +608,10 @@ transmit_download_request (void *cls, | |||
608 | memset (sm, 0, sizeof (struct SearchMessage)); | 608 | memset (sm, 0, sizeof (struct SearchMessage)); |
609 | sm->header.size = htons (sizeof (struct SearchMessage)); | 609 | sm->header.size = htons (sizeof (struct SearchMessage)); |
610 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 610 | sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
611 | if (dc->pending->depth == dc->treedepth) | ||
612 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_DBLOCK); | ||
613 | else | ||
614 | sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_IBLOCK); | ||
611 | sm->anonymity_level = htonl (dc->anonymity); | 615 | sm->anonymity_level = htonl (dc->anonymity); |
612 | sm->target = dc->target.hashPubKey; | 616 | sm->target = dc->target.hashPubKey; |
613 | sm->query = dc->pending->chk.query; | 617 | sm->query = dc->pending->chk.query; |
diff --git a/src/fs/fs_test_lib_data.conf b/src/fs/fs_test_lib_data.conf index d62ee8c98..7ca0166a1 100644 --- a/src/fs/fs_test_lib_data.conf +++ b/src/fs/fs_test_lib_data.conf | |||
@@ -46,7 +46,7 @@ DEBUG = YES | |||
46 | PORT = 43471 | 46 | PORT = 43471 |
47 | HOSTNAME = localhost | 47 | HOSTNAME = localhost |
48 | DEBUG = YES | 48 | DEBUG = YES |
49 | #PREFIX = valgrind --tool=memcheck --leak-check=yes | 49 | PREFIX = valgrind --tool=memcheck --leak-check=yes |
50 | #BINARY = /home/grothoff/bin/gnunet-service-fs | 50 | #BINARY = /home/grothoff/bin/gnunet-service-fs |
51 | #PREFIX = xterm -e gdb -x cmd --args | 51 | #PREFIX = xterm -e gdb -x cmd --args |
52 | 52 | ||
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 7ae9aaafa..efade8521 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -2174,6 +2174,7 @@ handle_p2p_get (void *cls, | |||
2174 | uint32_t ttl_decrement; | 2174 | uint32_t ttl_decrement; |
2175 | uint32_t type; | 2175 | uint32_t type; |
2176 | double preference; | 2176 | double preference; |
2177 | int have_ns; | ||
2177 | 2178 | ||
2178 | msize = ntohs(message->size); | 2179 | msize = ntohs(message->size); |
2179 | if (msize < sizeof (struct GetMessage)) | 2180 | if (msize < sizeof (struct GetMessage)) |
@@ -2182,6 +2183,18 @@ handle_p2p_get (void *cls, | |||
2182 | return GNUNET_SYSERR; | 2183 | return GNUNET_SYSERR; |
2183 | } | 2184 | } |
2184 | gm = (const struct GetMessage*) message; | 2185 | gm = (const struct GetMessage*) message; |
2186 | type = ntohl (gm->type); | ||
2187 | switch (type) | ||
2188 | { | ||
2189 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | ||
2190 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | ||
2191 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | ||
2192 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | ||
2193 | break; | ||
2194 | default: | ||
2195 | GNUNET_break_op (0); | ||
2196 | return GNUNET_SYSERR; | ||
2197 | } | ||
2185 | bm = ntohl (gm->hash_bitmap); | 2198 | bm = ntohl (gm->hash_bitmap); |
2186 | bits = 0; | 2199 | bits = 0; |
2187 | while (bm > 0) | 2200 | while (bm > 0) |
@@ -2249,11 +2262,12 @@ handle_p2p_get (void *cls, | |||
2249 | (unsigned int) ntohl (gm->type), | 2262 | (unsigned int) ntohl (gm->type), |
2250 | GNUNET_i2s (other)); | 2263 | GNUNET_i2s (other)); |
2251 | #endif | 2264 | #endif |
2265 | have_ns = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)); | ||
2252 | pr = GNUNET_malloc (sizeof (struct PendingRequest) + | 2266 | pr = GNUNET_malloc (sizeof (struct PendingRequest) + |
2253 | (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)?sizeof(GNUNET_HashCode):0); | 2267 | (have_ns ? sizeof(GNUNET_HashCode) : 0)); |
2254 | if ((bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) | 2268 | if (have_ns) |
2255 | pr->namespace = (GNUNET_HashCode*) &pr[1]; | 2269 | pr->namespace = (GNUNET_HashCode*) &pr[1]; |
2256 | pr->type = ntohl (gm->type); | 2270 | pr->type = type; |
2257 | pr->mingle = ntohl (gm->filter_mutator); | 2271 | pr->mingle = ntohl (gm->filter_mutator); |
2258 | if (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) | 2272 | if (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) |
2259 | memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode)); | 2273 | memcpy (&pr[1], &opt[bits++], sizeof (GNUNET_HashCode)); |
@@ -2354,7 +2368,6 @@ handle_p2p_get (void *cls, | |||
2354 | cps->inc_preference += preference; | 2368 | cps->inc_preference += preference; |
2355 | 2369 | ||
2356 | /* process locally */ | 2370 | /* process locally */ |
2357 | type = pr->type; | ||
2358 | if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) | 2371 | if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) |
2359 | type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */ | 2372 | type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */ |
2360 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, | 2373 | timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY, |
@@ -2438,6 +2451,19 @@ handle_start_search (void *cls, | |||
2438 | client_list = cl; | 2451 | client_list = cl; |
2439 | } | 2452 | } |
2440 | type = ntohl (sm->type); | 2453 | type = ntohl (sm->type); |
2454 | switch (type) | ||
2455 | { | ||
2456 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | ||
2457 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | ||
2458 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | ||
2459 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | ||
2460 | break; | ||
2461 | default: | ||
2462 | GNUNET_break (0); | ||
2463 | GNUNET_SERVER_receive_done (client, | ||
2464 | GNUNET_SYSERR); | ||
2465 | return GNUNET_SYSERR; | ||
2466 | } | ||
2441 | #if DEBUG_FS | 2467 | #if DEBUG_FS |
2442 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2443 | "Received request for `%s' of type %u from local client\n", | 2469 | "Received request for `%s' of type %u from local client\n", |