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_NO
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
165 * to the given URI and if so return it.
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
190 * how it fits in with the overall query
191 * and notify the client accordingly.
193 * @param sc context for the overall query
194 * @param ent entry for the specific keyword
195 * @param uri the URI that was found
196 * @param meta metadata associated with the URI
197 * under the "ent" keyword
200 process_ksk_result (struct GNUNET_FS_SearchContext *sc,
201 struct SearchRequestEntry *ent,
202 const struct GNUNET_FS_Uri *uri,
203 const struct GNUNET_CONTAINER_MetaData *meta)
206 struct SearchResult *sr;
207 struct GetResultContext grc;
211 if (! GNUNET_FS_uri_test_chk (uri))
216 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key,
217 &uri->data.chk.chk.query,
220 GNUNET_CONTAINER_multihashmap_get_multiple (ent->results,
222 &test_result_present,
224 return; /* duplicate result */
225 /* try to find search result in master map */
228 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map,
233 is_new = (NULL == sr) || (sr->mandatory_missing > 0);
236 sr = GNUNET_malloc (sizeof (struct SearchResult));
237 sr->uri = GNUNET_FS_uri_dup (uri);
238 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
239 sr->mandatory_missing = sc->mandatory_count;
240 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map,
243 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
247 /* FIXME: consider combining the meta data */
249 /* check if mandatory satisfied */
251 sr->mandatory_missing--;
253 sr->optional_support++;
254 if (0 != sr->mandatory_missing)
257 notify_client_chk_result (sc, sr);
259 notify_client_chk_update (sc, sr);
260 /* FIXME: consider starting probes for "sr" */
265 * Start search for content, internal API.
267 * @param h handle to the file sharing subsystem
268 * @param uri specifies the search parameters; can be
269 * a KSK URI or an SKS URI.
270 * @param anonymity desired level of anonymity
271 * @param cctx client context
272 * @param parent parent search (for namespace update searches)
273 * @return context that can be used to control the search
275 static struct GNUNET_FS_SearchContext *
276 search_start (struct GNUNET_FS_Handle *h,
277 const struct GNUNET_FS_Uri *uri,
280 struct GNUNET_FS_SearchContext *parent);
284 * We have received an SKS result. Start
285 * searching for updates and notify the
286 * client if it is a new result.
288 * @param sc context for the overall query
289 * @param id_update identifier for updates, NULL for none
290 * @param uri the URI that was found
291 * @param meta metadata associated with the URI
294 process_sks_result (struct GNUNET_FS_SearchContext *sc,
295 const char *id_update,
296 const struct GNUNET_FS_Uri *uri,
297 const struct GNUNET_CONTAINER_MetaData *meta)
299 struct GNUNET_FS_Uri uu;
301 struct SearchResult *sr;
304 if (! GNUNET_FS_uri_test_ksk (uri))
309 GNUNET_CRYPTO_hash_xor (&uri->data.chk.chk.key,
310 &uri->data.chk.chk.query,
313 GNUNET_CONTAINER_multihashmap_get_multiple (sc->master_result_map,
315 &test_result_present,
317 return; /* duplicate result */
318 sr = GNUNET_malloc (sizeof (struct SearchResult));
319 sr->uri = GNUNET_FS_uri_dup (uri);
320 sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta);
321 GNUNET_CONTAINER_multihashmap_put (sc->master_result_map,
324 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
325 /* FIXME: consider starting probes for "sr" */
328 notify_client_chk_result (sc, sr);
329 /* search for updates */
330 if (strlen (id_update) == 0)
331 return; /* no updates */
333 uu.data.sks.namespace = sc->uri->data.sks.namespace;
334 uu.data.sks.identifier = GNUNET_strdup (id_update);
335 /* FIXME: should attach update search
336 to the individual result, not
337 the entire SKS search! */
347 * Process a keyword-search result.
349 * @param sc our search context
350 * @param kb the kblock
351 * @param size size of kb
354 process_kblock (struct GNUNET_FS_SearchContext *sc,
355 const struct KBlock *kb,
361 char pt[size - sizeof (struct KBlock)];
362 struct GNUNET_CRYPTO_AesSessionKey skey;
363 struct GNUNET_CRYPTO_AesInitializationVector iv;
365 struct GNUNET_CONTAINER_MetaData *meta;
366 struct GNUNET_FS_Uri *uri;
369 GNUNET_CRYPTO_hash (&kb->keyspace,
370 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
373 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
375 &sc->requests[i].query,
376 sizeof (GNUNET_HashCode)))
378 if (i == sc->uri->data.ksk.keywordCount)
380 /* oops, does not match any of our keywords!? */
385 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv);
386 GNUNET_CRYPTO_aes_decrypt (&kb[1],
387 size - sizeof (struct KBlock),
392 eos = memchr (pt, 0, sizeof (pt));
399 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j],
403 GNUNET_break_op (0); /* kblock malformed */
406 uri = GNUNET_FS_uri_parse (pt, &emsg);
409 GNUNET_break_op (0); /* kblock malformed */
410 GNUNET_free_non_null (emsg);
411 GNUNET_CONTAINER_meta_data_destroy (meta);
415 process_ksk_result (sc, &sc->requests[i], uri, meta);
418 GNUNET_CONTAINER_meta_data_destroy (meta);
419 GNUNET_FS_uri_destroy (uri);
424 * Process a namespace-search result.
426 * @param sc our search context
427 * @param sb the sblock
428 * @param size size of sb
431 process_sblock (struct GNUNET_FS_SearchContext *sc,
432 const struct SBlock *sb,
435 size_t len = size - sizeof (struct SBlock);
437 struct GNUNET_CRYPTO_AesSessionKey skey;
438 struct GNUNET_CRYPTO_AesInitializationVector iv;
439 struct GNUNET_FS_Uri *uri;
440 struct GNUNET_CONTAINER_MetaData *meta;
449 identifier = sc->uri->data.sks.identifier;
450 GNUNET_CRYPTO_hash (identifier,
453 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
454 GNUNET_CRYPTO_aes_encrypt (&sb[1],
460 off = GNUNET_STRINGS_buffer_tokenize (pt,
467 GNUNET_break_op (0); /* sblock malformed */
470 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off],
474 GNUNET_break_op (0); /* sblock malformed */
477 uri = GNUNET_FS_uri_parse (uris, &emsg);
480 GNUNET_break_op (0); /* sblock malformed */
481 GNUNET_free_non_null (emsg);
482 GNUNET_CONTAINER_meta_data_destroy (meta);
486 process_sks_result (sc, id, uri, meta);
488 GNUNET_FS_uri_destroy (uri);
489 GNUNET_CONTAINER_meta_data_destroy (meta);
494 * Process a search result.
496 * @param sc our search context
497 * @param type type of the result
498 * @param expiration when it will expire
499 * @param data the (encrypted) response
500 * @param size size of data
503 process_result (struct GNUNET_FS_SearchContext *sc,
505 struct GNUNET_TIME_Absolute expiration,
509 if (GNUNET_TIME_absolute_get_duration (expiration).value > 0)
510 return; /* result expired */
513 case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
514 if (! GNUNET_FS_uri_test_ksk (sc->uri))
519 if (sizeof (struct KBlock) > size)
524 process_kblock (sc, data, size);
526 case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
527 if (! GNUNET_FS_uri_test_ksk (sc->uri))
532 if (sizeof (struct SBlock) > size)
537 process_sblock (sc, data, size);
539 case GNUNET_DATASTORE_BLOCKTYPE_ANY:
540 case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
541 case GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND:
542 case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
546 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
547 _("Got result with unknown block type `%d', ignoring"),
555 * Shutdown any existing connection to the FS
556 * service and try to establish a fresh one
557 * (and then re-transmit our search request).
559 * @param sc the search to reconnec
562 try_reconnect (struct GNUNET_FS_SearchContext *sc);
566 * Type of a function to call when we receive a message
570 * @param msg message received, NULL on timeout or fatal error
573 receive_results (void *cls,
574 const struct GNUNET_MessageHeader * msg)
576 struct GNUNET_FS_SearchContext *sc = cls;
577 const struct PutMessage *cm;
580 if ( (NULL == msg) ||
581 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
582 (ntohs (msg->size) <= sizeof (struct PutMessage)) )
587 msize = ntohs (msg->size);
588 cm = (const struct PutMessage*) msg;
591 GNUNET_TIME_absolute_ntoh (cm->expiration),
593 msize - sizeof (struct PutMessage));
594 /* continue receiving */
595 GNUNET_CLIENT_receive (sc->client,
598 GNUNET_TIME_UNIT_FOREVER_REL);
603 * We're ready to transmit the search request to the
604 * file-sharing service. Do it.
607 * @param size number of bytes available in buf
608 * @param buf where the callee should write the message
609 * @return number of bytes written to buf
612 transmit_search_request (void *cls,
616 struct GNUNET_FS_SearchContext *sc = cls;
618 struct SearchMessage *sm;
620 const char *identifier;
628 if (GNUNET_FS_uri_test_ksk (sc->uri))
630 msize = sizeof (struct SearchMessage) * sc->uri->data.ksk.keywordCount;
631 GNUNET_assert (size >= msize);
633 memset (sm, 0, msize);
634 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
636 sm[i].header.size = htons (sizeof (struct SearchMessage));
637 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
638 sm[i].anonymity_level = htonl (sc->anonymity);
639 sm[i].query = sc->requests[i].query;
644 msize = sizeof (struct SearchMessage);
645 GNUNET_assert (size >= msize);
647 memset (sm, 0, msize);
648 sm->header.size = htons (sizeof (struct SearchMessage));
649 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
650 sm->anonymity_level = htonl (sc->anonymity);
651 sm->target = sc->uri->data.sks.namespace;
652 identifier = sc->uri->data.sks.identifier;
653 GNUNET_CRYPTO_hash (identifier,
656 GNUNET_CRYPTO_hash_xor (&idh,
660 GNUNET_CLIENT_receive (sc->client,
663 GNUNET_TIME_UNIT_FOREVER_REL);
669 * Reconnect to the FS service and transmit
672 * @param cls our search context
676 do_reconnect (void *cls,
677 const struct GNUNET_SCHEDULER_TaskContext *tc)
679 struct GNUNET_FS_SearchContext *sc = cls;
680 struct GNUNET_CLIENT_Connection *client;
683 sc->task = GNUNET_SCHEDULER_NO_TASK;
684 client = GNUNET_CLIENT_connect (sc->h->sched,
693 if (GNUNET_FS_uri_test_ksk (sc->uri))
694 size = sizeof (struct SearchMessage) * sc->uri->data.ksk.keywordCount;
696 size = sizeof (struct SearchMessage);
697 GNUNET_CLIENT_notify_transmit_ready (client,
699 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
701 &transmit_search_request,
707 * Shutdown any existing connection to the FS
708 * service and try to establish a fresh one
709 * (and then re-transmit our search request).
711 * @param sc the search to reconnec
714 try_reconnect (struct GNUNET_FS_SearchContext *sc)
716 if (NULL != sc->client)
718 GNUNET_CLIENT_disconnect (sc->client);
722 = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
723 GNUNET_TIME_UNIT_SECONDS,
730 * Start search for content, internal API.
732 * @param h handle to the file sharing subsystem
733 * @param uri specifies the search parameters; can be
734 * a KSK URI or an SKS URI.
735 * @param anonymity desired level of anonymity
736 * @param cctx initial value for the client context
737 * @param parent parent search (for namespace update searches)
738 * @return context that can be used to control the search
740 static struct GNUNET_FS_SearchContext *
741 search_start (struct GNUNET_FS_Handle *h,
742 const struct GNUNET_FS_Uri *uri,
745 struct GNUNET_FS_SearchContext *parent)
747 struct GNUNET_FS_SearchContext *sc;
748 struct GNUNET_CLIENT_Connection *client;
749 struct GNUNET_FS_ProgressInfo pi;
754 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
755 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
757 if (GNUNET_FS_uri_test_ksk (uri))
759 size = sizeof (struct SearchMessage) * uri->data.ksk.keywordCount;
763 GNUNET_assert (GNUNET_FS_uri_test_sks (uri));
764 size = sizeof (struct SearchMessage);
766 if (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
768 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
769 _("Too many keywords specified for a single search."));
772 client = GNUNET_CLIENT_connect (h->sched,
777 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext));
779 sc->uri = GNUNET_FS_uri_dup (uri);
780 sc->anonymity = anonymity;
781 sc->start_time = GNUNET_TIME_absolute_get ();
784 sc->master_result_map = GNUNET_CONTAINER_multihashmap_create (16);
785 sc->client_info = cctx;
787 sc->requests = GNUNET_malloc (sizeof (struct SearchRequestEntry) *
788 sc->uri->data.ksk.keywordCount);
789 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
791 keyword = &sc->uri->data.ksk.keywords[i][1];
792 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc);
793 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc);
794 GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
795 GNUNET_CRYPTO_rsa_key_free (pk);
796 GNUNET_CRYPTO_hash (&pub,
797 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
798 &sc->requests[i].query);
799 sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
800 if (sc->requests[i].mandatory)
801 sc->mandatory_count++;
802 sc->requests[i].results = GNUNET_CONTAINER_multihashmap_create (4);
803 GNUNET_CRYPTO_hash (keyword,
805 &sc->requests[i].key);
809 // FIXME: need to track children
810 // in parent in case parent is stopped!
812 pi.status = GNUNET_FS_STATUS_SEARCH_START;
813 make_search_status (&pi, sc);
814 sc->client_info = h->upcb (h->upcb_cls,
816 GNUNET_CLIENT_notify_transmit_ready (client,
818 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
820 &transmit_search_request,
827 * Start search for content.
829 * @param h handle to the file sharing subsystem
830 * @param uri specifies the search parameters; can be
831 * a KSK URI or an SKS URI.
832 * @param anonymity desired level of anonymity
833 * @param cctx initial value for the client context
834 * @return context that can be used to control the search
836 struct GNUNET_FS_SearchContext *
837 GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
838 const struct GNUNET_FS_Uri *uri,
842 return search_start (h, uri, anonymity, cctx, NULL);
849 * @param sc context for the search that should be paused
852 GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
854 struct GNUNET_FS_ProgressInfo pi;
856 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
857 GNUNET_SCHEDULER_cancel (sc->h->sched,
859 sc->task = GNUNET_SCHEDULER_NO_TASK;
860 if (NULL != sc->client)
861 GNUNET_CLIENT_disconnect (sc->client);
863 // FIXME: make persistent!
864 // FIXME: should this freeze all active probes?
865 pi.status = GNUNET_FS_STATUS_SEARCH_PAUSED;
866 make_search_status (&pi, sc);
867 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
873 * Continue paused search.
875 * @param sc context for the search that should be resumed
878 GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc)
880 struct GNUNET_FS_ProgressInfo pi;
882 GNUNET_assert (sc->client == NULL);
883 GNUNET_assert (sc->task == GNUNET_SCHEDULER_NO_TASK);
884 do_reconnect (sc, NULL);
885 // FIXME: make persistent!
886 pi.status = GNUNET_FS_STATUS_SEARCH_CONTINUED;
887 make_search_status (&pi, sc);
888 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
894 * Free the given search result.
896 * @param cls the global FS handle
897 * @param key the key for the search result (unused)
898 * @param value the search result to free
902 search_result_free (void *cls,
903 const GNUNET_HashCode * key,
906 struct GNUNET_FS_SearchContext *sc = cls;
907 struct GNUNET_FS_Handle *h = sc->h;
908 struct SearchResult *sr = value;
909 struct GNUNET_FS_ProgressInfo pi;
911 pi.status = GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED;
912 make_search_status (&pi, sc);
913 pi.value.search.specifics.result_stopped.cctx = sr->client_info;
914 pi.value.search.specifics.result_stopped.meta = sr->meta;
915 pi.value.search.specifics.result_stopped.uri = sr->uri;
916 sr->client_info = h->upcb (h->upcb_cls,
918 GNUNET_break (NULL == sr->client_info);
920 GNUNET_FS_uri_destroy (sr->uri);
921 GNUNET_CONTAINER_meta_data_destroy (sr->meta);
922 if (sr->probe_ctx != NULL)
924 GNUNET_FS_download_stop (sr->probe_ctx, GNUNET_YES);
926 /* FIXME: trigger starting of new
927 probes here!? Maybe not -- could
928 cause new probes to be immediately
931 if (sr->probe_cancel_task != GNUNET_SCHEDULER_NO_TASK)
933 GNUNET_SCHEDULER_cancel (h->sched,
934 sr->probe_cancel_task);
942 * Stop search for content.
944 * @param sc context for the search that should be stopped
947 GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
949 struct GNUNET_FS_ProgressInfo pi;
952 // FIXME: make un-persistent!
953 if (NULL != sc->parent)
955 // FIXME: need to untrack sc
958 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
961 pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED;
962 make_search_status (&pi, sc);
963 sc->client_info = sc->h->upcb (sc->h->upcb_cls,
965 GNUNET_break (NULL == sc->client_info);
966 if (sc->task != GNUNET_SCHEDULER_NO_TASK)
967 GNUNET_SCHEDULER_cancel (sc->h->sched,
969 if (NULL != sc->client)
970 GNUNET_CLIENT_disconnect (sc->client);
971 GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
972 for (i=0;i<sc->uri->data.ksk.keywordCount;i++)
973 GNUNET_CONTAINER_multihashmap_destroy (sc->requests[i].results);
974 GNUNET_free_non_null (sc->requests);
975 GNUNET_FS_uri_destroy (sc->uri);
979 /* end of fs_search.c */