2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file fs/fs_search.c
23 * @brief Helper functions for searching.
24 * @author Christian Grothoff
27 * - handle SKS updates searches nicely (can wait)
28 * - handle availability probes (can wait)
29 * - make operations persistent (can wait)
30 * - handle namespace advertisements (can wait)
31 * - add support for pushing "already seen" information
32 * to FS service for bloomfilter (can wait)
36 #include "gnunet_constants.h"
37 #include "gnunet_fs_service.h"
38 #include "gnunet_protocols.h"
41 #define DEBUG_SEARCH GNUNET_YES
46 * Fill in all of the generic fields for
49 * @param pi structure to fill in
50 * @param sc overall search context
53 make_search_status (struct GNUNET_FS_ProgressInfo *pi,
54 struct GNUNET_FS_SearchContext *sc)
56 pi->value.search.sc = sc;
60 = (sc->parent == NULL) ? NULL : sc->parent->client_info;
61 pi->value.search.query
63 pi->value.search.duration = GNUNET_TIME_absolute_get_duration (sc->start_time);
64 pi->value.search.anonymity = sc->anonymity;
69 * Check if the given result is identical
72 * @param cls points to the URI we check against
74 * @param value a "struct SearchResult" who's URI we
76 * @return GNUNET_SYSERR if the result is present,
80 test_result_present (void *cls,
81 const GNUNET_HashCode * key,
84 const struct GNUNET_FS_Uri *uri = cls;
85 struct SearchResult *sr = value;
87 if (GNUNET_FS_uri_test_equal (uri,
95 * We've found a new CHK result. Let the client
98 * @param sc the search context
99 * @param sr the specific result
102 notify_client_chk_result (struct GNUNET_FS_SearchContext *sc,
103 struct SearchResult *sr)
105 struct GNUNET_FS_ProgressInfo pi;
107 pi.status = GNUNET_FS_STATUS_SEARCH_RESULT;
108 make_search_status (&pi, sc);
109 pi.value.search.specifics.result.meta = sr->meta;
110 pi.value.search.specifics.result.uri = sr->uri;
111 sr->client_info = sc->h->upcb (sc->h->upcb_cls,
117 * We've found new information about an existing CHK result. Let the
118 * client know about it.
120 * @param sc the search context
121 * @param sr the specific result
124 notify_client_chk_update (struct GNUNET_FS_SearchContext *sc,
125 struct SearchResult *sr)
127 struct GNUNET_FS_ProgressInfo pi;
129 pi.status = GNUNET_FS_STATUS_SEARCH_UPDATE;
130 make_search_status (&pi, sc);
131 pi.value.search.specifics.update.cctx = sr->client_info;
132 pi.value.search.specifics.update.meta = sr->meta;
133 pi.value.search.specifics.update.uri = sr->uri;
134 pi.value.search.specifics.update.availability_rank
135 = 2*sr->availability_success - sr->availability_trials;
136 pi.value.search.specifics.update.availability_certainty
137 = sr->availability_trials;
138 pi.value.search.specifics.update.applicability_rank
139 = sr->optional_support;
140 sr->client_info = sc->h->upcb (sc->h->upcb_cls,
146 * Context for "get_result_present".
148 struct GetResultContext
151 * The URI we're looking for.
153 const struct GNUNET_FS_Uri *uri;
156 * Where to store a pointer to the search
157 * result struct if we found a match.
159 struct SearchResult *sr;
164 * Check if the given result is identical to the given URI and if so
167 * @param cls a "struct GetResultContext"
168 * @param key not used
169 * @param value a "struct SearchResult" who's URI we
170 * should compare with
174 get_result_present (void *cls,
175 const GNUNET_HashCode * key,
178 struct GetResultContext *grc = cls;
179 struct SearchResult *sr = value;
181 if (GNUNET_FS_uri_test_equal (grc->uri,
189 * We have received a KSK result. Check how it fits in with the
190 * overall query and notify the client accordingly.
192 * @param sc context for the overall query
193 * @param ent entry for the specific keyword
194 * @param uri the URI that was found
195 * @param meta metadata associated with the URI
196 * under the "ent" keyword
199 process_ksk_result (struct GNUNET_FS_SearchContext *sc,
200 struct SearchRequestEntry *ent,
201 const struct GNUNET_FS_Uri *uri,
202 const struct GNUNET_CONTAINER_MetaData *meta)
205 struct SearchResult *sr;
206 struct GetResultContext grc;
210 GNUNET_FS_uri_to_key (uri, &key);
212 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results,
214 &test_result_present,
216 return; /* duplicate result */
217 /* try to find search result in master map */
220 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map,
225 is_new = (NULL == sr) || (sr->mandatory_missing > 0);
228 sr = GNUNET_malloc (sizeof (struct SearchResult));
229 sr->uri = GNUNET_FS_uri_dup (uri);
230 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
231 sr->mandatory_missing = sc->mandatory_count;
232 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map,
235 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
239 /* FIXME: consider combining the meta data */
241 /* check if mandatory satisfied */
243 sr->mandatory_missing--;
245 sr->optional_support++;
246 if (0 != sr->mandatory_missing)
249 notify_client_chk_result (sc, sr);
251 notify_client_chk_update (sc, sr);
252 /* FIXME: consider starting probes for "sr" */
257 * Start search for content, internal API.
259 * @param h handle to the file sharing subsystem
260 * @param uri specifies the search parameters; can be
261 * a KSK URI or an SKS URI.
262 * @param anonymity desired level of anonymity
263 * @param cctx client context
264 * @param parent parent search (for namespace update searches)
265 * @return context that can be used to control the search
267 static struct GNUNET_FS_SearchContext *
268 search_start (struct GNUNET_FS_Handle *h,
269 const struct GNUNET_FS_Uri *uri,
272 struct GNUNET_FS_SearchContext *parent);
276 * We have received an SKS result. Start searching for updates and
277 * notify the client if it is a new result.
279 * @param sc context for the overall query
280 * @param id_update identifier for updates, NULL for none
281 * @param uri the URI that was found
282 * @param meta metadata associated with the URI
285 process_sks_result (struct GNUNET_FS_SearchContext *sc,
286 const char *id_update,
287 const struct GNUNET_FS_Uri *uri,
288 const struct GNUNET_CONTAINER_MetaData *meta)
290 struct GNUNET_FS_Uri uu;
292 struct SearchResult *sr;
295 GNUNET_FS_uri_to_key (uri, &key);
296 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key,
297 &uri->data.chk.chk.query,
300 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map,
302 &test_result_present,
304 return; /* duplicate result */
305 sr = GNUNET_malloc (sizeof (struct SearchResult));
306 sr->uri = GNUNET_FS_uri_dup (uri);
307 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
308 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map,
311 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
312 /* FIXME: consider starting probes for "sr" */
315 notify_client_chk_result (sc, sr);
316 /* search for updates */
317 if (strlen (id_update) == 0)
318 return; /* no updates */
320 uu.data.sks.namespace = sc->uri->data.sks.namespace;
321 uu.data.sks.identifier = GNUNET_strdup (id_update);
322 /* FIXME: should attach update search
323 to the individual result, not
324 the entire SKS search! */
334 * Process a keyword-search result.
336 * @param sc our search context
337 * @param kb the kblock
338 * @param size size of kb
341 process_kblock (struct GNUNET_FS_SearchContext *sc,
342 const struct KBlock *kb,
348 char pt[size - sizeof (struct KBlock)];
349 struct GNUNET_CRYPTO_AesSessionKey skey;
350 struct GNUNET_CRYPTO_AesInitializationVector iv;
352 struct GNUNET_CONTAINER_MetaData *meta;
353 struct GNUNET_FS_Uri *uri;
356 GNUNET_CRYPTO_hash (&kb->keyspace,
357 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
360 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
362 &sc->requests[i].query,
363 sizeof (GNUNET_HashCode)))
365 if (i == sc->uri->data.ksk.keywordCount)
367 /* oops, does not match any of our keywords!? */
372 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
373 GNUNET_CRYPTO_aes_decrypt (&kb[1],
374 size - sizeof (struct KBlock),
379 eos = memchr (pt, 0, sizeof (pt));
386 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j],
390 GNUNET_break_op (0); /* kblock malformed */
393 uri = GNUNET_FS_uri_parse (pt, &emsg);
396 GNUNET_break_op (0); /* kblock malformed */
397 GNUNET_free_non_null (emsg);
398 GNUNET_CONTAINER_meta_data_destroy (meta);
402 process_ksk_result (sc, &sc->requests[i], uri, meta);
405 GNUNET_CONTAINER_meta_data_destroy (meta);
406 GNUNET_FS_uri_destroy (uri);
411 * Process a namespace-search result.
413 * @param sc our search context
414 * @param sb the sblock
415 * @param size size of sb
418 process_sblock (struct GNUNET_FS_SearchContext *sc,
419 const struct SBlock *sb,
422 size_t len = size - sizeof (struct SBlock);
424 struct GNUNET_CRYPTO_AesSessionKey skey;
425 struct GNUNET_CRYPTO_AesInitializationVector iv;
426 struct GNUNET_FS_Uri *uri;
427 struct GNUNET_CONTAINER_MetaData *meta;
436 identifier = sc->uri->data.sks.identifier;
437 GNUNET_CRYPTO_hash (identifier,
440 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
441 GNUNET_CRYPTO_aes_encrypt (&sb[1],
447 off = GNUNET_STRINGS_buffer_tokenize (pt,
454 GNUNET_break_op (0); /* sblock malformed */
457 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off],
461 GNUNET_break_op (0); /* sblock malformed */
464 uri = GNUNET_FS_uri_parse (uris, &emsg);
467 GNUNET_break_op (0); /* sblock malformed */
468 GNUNET_free_non_null (emsg);
469 GNUNET_CONTAINER_meta_data_destroy (meta);
473 process_sks_result (sc, id, uri, meta);
475 GNUNET_FS_uri_destroy (uri);
476 GNUNET_CONTAINER_meta_data_destroy (meta);
481 * Process a search result.
483 * @param sc our search context
484 * @param type type of the result
485 * @param expiration when it will expire
486 * @param data the (encrypted) response
487 * @param size size of data
490 process_result (struct GNUNET_FS_SearchContext *sc,
492 struct GNUNET_TIME_Absolute expiration,
496 if (GNUNET_TIME_absolute_get_duration (expiration).value > 0)
497 return; /* result expired */
500 case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
501 if (! GNUNET_FS_uri_test_ksk (sc->uri))
506 if (sizeof (struct KBlock) > size)
511 process_kblock (sc, data, size);
513 case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
514 if (! GNUNET_FS_uri_test_ksk (sc->uri))
519 if (sizeof (struct SBlock) > size)
524 process_sblock (sc, data, size);
526 case GNUNET_DATASTORE_BLOCKTYPE_ANY:
527 case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
528 case GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND:
529 case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
533 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
534 _("Got result with unknown block type `%d', ignoring"),
542 * Shutdown any existing connection to the FS
543 * service and try to establish a fresh one
544 * (and then re-transmit our search request).
546 * @param sc the search to reconnec
549 try_reconnect (struct GNUNET_FS_SearchContext *sc);
553 * Type of a function to call when we receive a message
557 * @param msg message received, NULL on timeout or fatal error
560 receive_results (void *cls,
561 const struct GNUNET_MessageHeader * msg)
563 struct GNUNET_FS_SearchContext *sc = cls;
564 const struct PutMessage *cm;
567 if ( (NULL == msg) ||
568 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
569 (ntohs (msg->size) <= sizeof (struct PutMessage)) )
574 msize = ntohs (msg->size);
575 cm = (const struct PutMessage*) msg;
578 GNUNET_TIME_absolute_ntoh (cm->expiration),
580 msize - sizeof (struct PutMessage));
581 /* continue receiving */
582 GNUNET_CLIENT_receive (sc->client,
585 GNUNET_TIME_UNIT_FOREVER_REL);
590 * We're ready to transmit the search request to the
591 * file-sharing service. Do it.
594 * @param size number of bytes available in buf
595 * @param buf where the callee should write the message
596 * @return number of bytes written to buf
599 transmit_search_request (void *cls,
603 struct GNUNET_FS_SearchContext *sc = cls;
605 struct SearchMessage *sm;
607 const char *identifier;
616 if (GNUNET_FS_uri_test_ksk (sc->uri))
618 msize = sizeof (struct SearchMessage) * sc->uri->data.ksk.keywordCount;
619 GNUNET_assert (size >= msize);
621 memset (sm, 0, msize);
622 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
624 sm[i].header.size = htons (sizeof (struct SearchMessage));
625 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
626 sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_KBLOCK);
627 sm[i].anonymity_level = htonl (sc->anonymity);
628 sm[i].query = sc->requests[i].query;
633 GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
634 msize = sizeof (struct SearchMessage);
635 GNUNET_assert (size >= msize);
637 memset (sm, 0, msize);
638 sm->header.size = htons (sizeof (struct SearchMessage));
639 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
640 sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_SBLOCK);
641 sm->anonymity_level = htonl (sc->anonymity);
642 sm->target = sc->uri->data.sks.namespace;
643 identifier = sc->uri->data.sks.identifier;
644 GNUNET_CRYPTO_hash (identifier,
647 GNUNET_CRYPTO_hash (&key,
648 sizeof (GNUNET_HashCode),
650 GNUNET_CRYPTO_hash_xor (&idh,
654 GNUNET_CLIENT_receive (sc->client,
657 GNUNET_TIME_UNIT_FOREVER_REL);
663 * Reconnect to the FS service and transmit
666 * @param cls our search context
670 do_reconnect (void *cls,
671 const struct GNUNET_SCHEDULER_TaskContext *tc)
673 struct GNUNET_FS_SearchContext *sc = cls;
674 struct GNUNET_CLIENT_Connection *client;
677 sc->task = GNUNET_SCHEDULER_NO_TASK;
678 client = GNUNET_CLIENT_connect (sc->h->sched,
687 if (GNUNET_FS_uri_test_ksk (sc->uri))
688 size = sizeof (struct SearchMessage) * sc->uri->data.ksk.keywordCount;
690 size = sizeof (struct SearchMessage);
691 GNUNET_CLIENT_notify_transmit_ready (client,
693 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
695 &transmit_search_request,
701 * Shutdown any existing connection to the FS
702 * service and try to establish a fresh one
703 * (and then re-transmit our search request).
705 * @param sc the search to reconnec
708 try_reconnect (struct GNUNET_FS_SearchContext *sc)
710 if (NULL != sc->client)
712 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
716 = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
717 GNUNET_TIME_UNIT_SECONDS,
724 * Start search for content, internal API.
726 * @param h handle to the file sharing subsystem
727 * @param uri specifies the search parameters; can be
728 * a KSK URI or an SKS URI.
729 * @param anonymity desired level of anonymity
730 * @param cctx initial value for the client context
731 * @param parent parent search (for namespace update searches)
732 * @return context that can be used to control the search
734 static struct GNUNET_FS_SearchContext *
735 search_start (struct GNUNET_FS_Handle *h,
736 const struct GNUNET_FS_Uri *uri,
739 struct GNUNET_FS_SearchContext *parent)
741 struct GNUNET_FS_SearchContext *sc;
742 struct GNUNET_CLIENT_Connection *client;
743 struct GNUNET_FS_ProgressInfo pi;
748 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
749 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
751 if (GNUNET_FS_uri_test_ksk (uri))
753 size = sizeof (struct SearchMessage) * uri->data.ksk.keywordCount;
757 GNUNET_assert (GNUNET_FS_uri_test_sks (uri));
758 size = sizeof (struct SearchMessage);
760 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
762 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
763 _("Too many keywords specified for a single search."));
766 client = GNUNET_CLIENT_connect (h->sched,
771 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext));
773 sc->uri = GNUNET_FS_uri_dup (uri);
774 sc->anonymity = anonymity;
775 sc->start_time = GNUNET_TIME_absolute_get ();
778 sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16);
779 sc->client_info = cctx;
780 if (GNUNET_FS_uri_test_ksk (uri))
782 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
783 sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) *
784 sc->uri->data.ksk.keywordCount);
785 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
787 keyword = &sc->uri->data.ksk.keywords[i][1];
788 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc);
789 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc);
790 GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
791 GNUNET_CRYPTO_rsa_key_free (pk);
792 GNUNET_CRYPTO_hash (&pub,
793 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
794 &sc->requests[i].query);
795 sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
796 if (sc->requests[i].mandatory)
797 sc->mandatory_count++;
798 sc->requests[i].results = GNUNET_CONTAINER_multihashmap_create (4);
799 GNUNET_CRYPTO_hash (keyword,
801 &sc->requests[i].key);
806 // FIXME: need to track children
807 // in parent in case parent is stopped!
809 pi.status = GNUNET_FS_STATUS_SEARCH_START;
810 make_search_status (&pi, sc);
811 sc->client_info = h->upcb (h->upcb_cls,
813 GNUNET_CLIENT_notify_transmit_ready (client,
815 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
817 &transmit_search_request,
824 * Start search for content.
826 * @param h handle to the file sharing subsystem
827 * @param uri specifies the search parameters; can be
828 * a KSK URI or an SKS URI.
829 * @param anonymity desired level of anonymity
830 * @param cctx initial value for the client context
831 * @return context that can be used to control the search
833 struct GNUNET_FS_SearchContext *
834 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
835 const struct GNUNET_FS_Uri *uri,
839 return search_start (h, uri, anonymity, cctx, NULL);
846 * @param sc context for the search that should be paused
849 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
851 struct GNUNET_FS_ProgressInfo pi;
853 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
854 GNUNET_SCHEDULER_cancel (sc->h->sched,
856 sc->task = GNUNET_SCHEDULER_NO_TASK;
857 if (NULL != sc->client)
858 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
860 // FIXME: make persistent!
861 // FIXME: should this freeze all active probes?
862 pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED;
863 make_search_status (&pi, sc);
864 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
870 * Continue paused search.
872 * @param sc context for the search that should be resumed
875 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc)
877 struct GNUNET_FS_ProgressInfo pi;
879 GNUNET_assert (sc->client == NULL);
880 GNUNET_assert (sc->task == GNUNET_SCHEDULER_NO_TASK);
881 do_reconnect (sc, NULL);
882 // FIXME: make persistent!
883 pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED;
884 make_search_status (&pi, sc);
885 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
891 * Free the given search result.
893 * @param cls the global FS handle
894 * @param key the key for the search result (unused)
895 * @param value the search result to free
899 search_result_free (void *cls,
900 const GNUNET_HashCode * key,
903 struct GNUNET_FS_SearchContext *sc = cls;
904 struct GNUNET_FS_Handle *h = sc->h;
905 struct SearchResult *sr = value;
906 struct GNUNET_FS_ProgressInfo pi;
908 pi.status = GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED;
909 make_search_status (&pi, sc);
910 pi.value.search.specifics.result_stopped.cctx = sr->client_info;
911 pi.value.search.specifics.result_stopped.meta = sr->meta;
912 pi.value.search.specifics.result_stopped.uri = sr->uri;
913 sr->client_info = h->upcb (h->upcb_cls,
915 GNUNET_break (NULL == sr->client_info);
917 GNUNET_FS_uri_destroy (sr->uri);
918 GNUNET_CONTAINER_meta_data_destroy (sr->meta);
919 if (sr->probe_ctx != NULL)
921 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);
923 /* FIXME: trigger starting of new
924 probes here!? Maybe not -- could
925 cause new probes to be immediately
928 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
930 GNUNET_SCHEDULER_cancel (h->sched,
931 sr->probe_cancel_task);
939 * Stop search for content.
941 * @param sc context for the search that should be stopped
944 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
946 struct GNUNET_FS_ProgressInfo pi;
949 // FIXME: make un-persistent!
950 if (NULL != sc->parent)
952 // FIXME: need to untrack sc
955 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
958 pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED;
959 make_search_status (&pi, sc);
960 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
962 GNUNET_break (NULL == sc->client_info);
963 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
964 GNUNET_SCHEDULER_cancel (sc->h->sched,
966 if (NULL != sc->client)
967 GNUNET_CLIENT_disconnect (sc->client, GNUNET_NO);
968 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
969 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
970 GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
971 GNUNET_free_non_null (sc->requests);
972 GNUNET_FS_uri_destroy (sc->uri);
976 /* end of fs_search.c */