aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-15 12:39:52 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-15 12:39:52 +0000
commit62734197ffae55d0d21ed3bc789d5529e9d02fd4 (patch)
treef49cd18187f8106bfdf8721783a23e1389a27005 /src/fs
parent6ad3fb49f0745731a820473539436be99c4ba4b3 (diff)
downloadgnunet-62734197ffae55d0d21ed3bc789d5529e9d02fd4.tar.gz
gnunet-62734197ffae55d0d21ed3bc789d5529e9d02fd4.zip
fixing 1786
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-service-fs.c21
-rw-r--r--src/fs/gnunet-service-fs_lc.c100
-rw-r--r--src/fs/gnunet-service-fs_lc.h10
3 files changed, 77 insertions, 54 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 48b7bca29..c1ff17814 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -402,14 +402,25 @@ handle_start_search (void *cls, struct GNUNET_SERVER_Client *client,
402 const struct GNUNET_MessageHeader *message) 402 const struct GNUNET_MessageHeader *message)
403{ 403{
404 struct GSF_PendingRequest *pr; 404 struct GSF_PendingRequest *pr;
405 int ret;
405 406
406 pr = GSF_local_client_start_search_handler_ (client, message); 407 pr = NULL;
407 if (NULL == pr) 408 ret = GSF_local_client_start_search_handler_ (client, message,
409 &pr);
410 switch (ret)
408 { 411 {
409 /* GNUNET_SERVER_receive_done was already called! */ 412 case GNUNET_SYSERR:
410 return; 413 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
414 break;
415 case GNUNET_NO:
416 GNUNET_SERVER_receive_done (client, GNUNET_OK);
417 break;
418 case GNUNET_YES:
419 GSF_local_lookup_ (pr, &start_p2p_processing, client);
420 break;
421 default:
422 GNUNET_assert (0);
411 } 423 }
412 GSF_local_lookup_ (pr, &start_p2p_processing, client);
413} 424}
414 425
415 426
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index e2a6856fa..103d8de95 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -280,15 +280,22 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
280 280
281/** 281/**
282 * Handle START_SEARCH-message (search request from local client). 282 * Handle START_SEARCH-message (search request from local client).
283 * Only responsible for creating the request entry itself and setting
284 * up reply callback and cancellation on client disconnect. Does NOT
285 * execute the actual request strategy (planning).
283 * 286 *
284 * @param client identification of the client 287 * @param client identification of the client
285 * @param message the actual message 288 * @param message the actual message
286 * @return pending request handle for the request, NULL on error 289 * @param where to store the pending request handle for the request
290 * @return GNUNET_YES to start local processing,
291 * GNUNET_NO to not (yet) start local processing,
292 * GNUNET_SYSERR on error
287 */ 293 */
288struct GSF_PendingRequest * 294int
289GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, 295GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
290 const struct GNUNET_MessageHeader 296 const struct GNUNET_MessageHeader
291 *message) 297 *message,
298 struct GSF_PendingRequest **prptr)
292{ 299{
293 static GNUNET_HashCode all_zeros; 300 static GNUNET_HashCode all_zeros;
294 const struct SearchMessage *sm; 301 const struct SearchMessage *sm;
@@ -305,8 +312,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
305 (0 != (msize - sizeof (struct SearchMessage)) % sizeof (GNUNET_HashCode))) 312 (0 != (msize - sizeof (struct SearchMessage)) % sizeof (GNUNET_HashCode)))
306 { 313 {
307 GNUNET_break (0); 314 GNUNET_break (0);
308 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 315 *prptr = NULL;
309 return NULL; 316 return GNUNET_SYSERR;
310 } 317 }
311 GNUNET_STATISTICS_update (GSF_stats, 318 GNUNET_STATISTICS_update (GSF_stats,
312 gettext_noop ("# client searches received"), 1, 319 gettext_noop ("# client searches received"), 1,
@@ -320,7 +327,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
320 GNUNET_h2s (&sm->query), (unsigned int) type); 327 GNUNET_h2s (&sm->query), (unsigned int) type);
321#endif 328#endif
322 lc = GSF_local_client_lookup_ (client); 329 lc = GSF_local_client_lookup_ (client);
323 330 cr = NULL;
324 /* detect duplicate KBLOCK requests */ 331 /* detect duplicate KBLOCK requests */
325 if ((type == GNUNET_BLOCK_TYPE_FS_KBLOCK) || 332 if ((type == GNUNET_BLOCK_TYPE_FS_KBLOCK) ||
326 (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || (type == GNUNET_BLOCK_TYPE_ANY)) 333 (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || (type == GNUNET_BLOCK_TYPE_ANY))
@@ -338,49 +345,50 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
338 break; 345 break;
339 cr = cr->next; 346 cr = cr->next;
340 } 347 }
341 if (cr != NULL) 348 }
342 { 349 if (cr != NULL)
350 {
343#if DEBUG_FS_CLIENT 351#if DEBUG_FS_CLIENT
344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
345 "Have existing request, merging content-seen lists.\n"); 353 "Have existing request, merging content-seen lists.\n");
346#endif 354#endif
347 GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1], 355 GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1],
348 sc); 356 sc);
349 GNUNET_STATISTICS_update (GSF_stats, 357 GNUNET_STATISTICS_update (GSF_stats,
350 gettext_noop 358 gettext_noop
351 ("# client searches updated (merged content seen list)"), 359 ("# client searches updated (merged content seen list)"),
352 1, GNUNET_NO); 360 1, GNUNET_NO);
353 GNUNET_SERVER_receive_done (client, GNUNET_OK); 361 }
354 return NULL; 362 else
355 } 363 {
364 GNUNET_STATISTICS_update (GSF_stats,
365 gettext_noop ("# client searches active"), 1,
366 GNUNET_NO);
367 cr = GNUNET_malloc (sizeof (struct ClientRequest));
368 cr->lc = lc;
369 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
370 options = GSF_PRO_LOCAL_REQUEST;
371 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
372 options |= GSF_PRO_LOCAL_ONLY;
373 cr->pr = GSF_pending_request_create_ (options, type, &sm->query,
374 (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
375 : NULL,
376 (0 !=
377 memcmp (&sm->target, &all_zeros,
378 sizeof (GNUNET_HashCode)))
379 ? (const struct GNUNET_PeerIdentity *)
380 &sm->target : NULL, NULL, 0,
381 0 /* bf */ ,
382 ntohl (sm->anonymity_level),
383 0 /* priority */ ,
384 0 /* ttl */ ,
385 0 /* sender PID */ ,
386 0 /* origin PID */ ,
387 (const GNUNET_HashCode *) &sm[1], sc,
388 &client_response_handler, cr);
356 } 389 }
357 390 *prptr = cr->pr;
358 GNUNET_STATISTICS_update (GSF_stats, 391 return (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl (sm->options))) ? GNUNET_NO : GNUNET_YES;
359 gettext_noop ("# client searches active"), 1,
360 GNUNET_NO);
361 cr = GNUNET_malloc (sizeof (struct ClientRequest));
362 cr->lc = lc;
363 GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr);
364 options = GSF_PRO_LOCAL_REQUEST;
365 if (0 != (GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
366 options |= GSF_PRO_LOCAL_ONLY;
367 cr->pr = GSF_pending_request_create_ (options, type, &sm->query,
368 (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */
369 : NULL,
370 (0 !=
371 memcmp (&sm->target, &all_zeros,
372 sizeof (GNUNET_HashCode)))
373 ? (const struct GNUNET_PeerIdentity *)
374 &sm->target : NULL, NULL, 0,
375 0 /* bf */ ,
376 ntohl (sm->anonymity_level),
377 0 /* priority */ ,
378 0 /* ttl */ ,
379 0 /* sender PID */ ,
380 0 /* origin PID */ ,
381 (const GNUNET_HashCode *) &sm[1], sc,
382 &client_response_handler, cr);
383 return cr->pr;
384} 392}
385 393
386 394
diff --git a/src/fs/gnunet-service-fs_lc.h b/src/fs/gnunet-service-fs_lc.h
index c625edf0b..ebfb12927 100644
--- a/src/fs/gnunet-service-fs_lc.h
+++ b/src/fs/gnunet-service-fs_lc.h
@@ -48,12 +48,16 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client);
48 * 48 *
49 * @param client identification of the client 49 * @param client identification of the client
50 * @param message the actual message 50 * @param message the actual message
51 * @return pending request handle for the request, NULL on error 51 * @param where to store the pending request handle for the request
52 * @return GNUNET_YES to start local processing,
53 * GNUNET_NO to not (yet) start local processing,
54 * GNUNET_SYSERR on error
52 */ 55 */
53struct GSF_PendingRequest * 56int
54GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, 57GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
55 const struct GNUNET_MessageHeader 58 const struct GNUNET_MessageHeader
56 *message); 59 *message,
60 struct GSF_PendingRequest **prptr);
57 61
58 62
59/** 63/**