2 This file is part of GNUnet.
3 (C) 2011 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 3, 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/gnunet-service-fs_cp.c
23 * @brief API to handle 'connected peers'
24 * @author Christian Grothoff
27 #include "gnunet-service-fs.h"
28 #include "gnunet-service-fs_cp.h"
31 * How often do we flush trust values to disk?
33 #define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
38 * Handle to cancel a transmission request.
40 struct GSF_PeerTransmitHandle
44 * Handle for an active request for transmission to this
45 * peer, or NULL (if core queue was full).
47 struct GNUNET_CORE_TransmitHandle *cth;
50 * Time when this transmission request was issued.
52 struct GNUNET_TIME_Absolute transmission_request_start_time;
55 * Timeout for this request.
57 struct GNUNET_TIME_Absolute timeout;
60 * Task called on timeout, or 0 for none.
62 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
65 * Function to call to get the actual message.
67 GSF_GetMessageCallback gmc;
70 * Peer this request targets.
72 struct GSF_ConnectedPeer *cp;
80 * Size of the message to be transmitted.
85 * GNUNET_YES if this is a query, GNUNET_NO for content.
90 * Priority of this request.
100 struct GSF_ConnectedPeer
104 * Performance data for this peer.
106 struct GSF_PeerPerformanceData ppd;
109 * Time until when we blocked this peer from migrating
112 struct GNUNET_TIME_Absolute last_migration_block;
115 * Messages (replies, queries, content migration) we would like to
116 * send to this peer in the near future. Sorted by priority, head.
118 struct GSF_PeerTransmitHandle *pth_head;
121 * Messages (replies, queries, content migration) we would like to
122 * send to this peer in the near future. Sorted by priority, tail.
124 struct GSF_PeerTransmitHandle *pth_tail;
127 * Context of our GNUNET_CORE_peer_change_preference call (or NULL).
128 * NULL if we have successfully reserved 32k, otherwise non-NULL.
130 struct GNUNET_CORE_InformationRequestContext *irc;
133 * ID of delay task for scheduling transmission.
135 GNUNET_SCHEDULER_TaskIdentifier delayed_transmission_request_task; // FIXME: unused!
138 * Increase in traffic preference still to be submitted
139 * to the core service for this peer.
141 uint64_t inc_preference;
144 * Trust rating for this peer
149 * Trust rating for this peer on disk.
154 * The peer's identity.
159 * Which offset in "last_p2p_replies" will be updated next?
160 * (we go round-robin).
162 unsigned int last_p2p_replies_woff;
165 * Which offset in "last_client_replies" will be updated next?
166 * (we go round-robin).
168 unsigned int last_client_replies_woff;
171 * Current offset into 'last_request_times' ring buffer.
173 unsigned int last_request_times_off;
179 * Map from peer identities to 'struct GSF_ConnectPeer' entries.
181 static struct GNUNET_CONTAINER_MultiHashMap *cp_map;
185 * Where do we store trust information?
187 static char *trustDirectory;
191 * Get the filename under which we would store the GNUNET_HELLO_Message
192 * for the given host and protocol.
193 * @return filename of the form DIRECTORY/HOSTID
196 get_trust_filename (const struct GNUNET_PeerIdentity *id)
198 struct GNUNET_CRYPTO_HashAsciiEncoded fil;
201 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil);
202 GNUNET_asprintf (&fn, "%s%s%s", trustDirectory, DIR_SEPARATOR_STR, &fil);
208 * Find latency information in 'atsi'.
210 * @param atsi performance data
211 * @return connection latency
213 static struct GNUNET_TIME_Relative
214 get_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi)
217 return GNUNET_TIME_UNIT_SECONDS;
218 while ( (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR) &&
219 (ntohl (atsi->type) != GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) )
221 if (ntohl (atsi->type) == GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR)
224 /* how can we not have latency data? */
225 return GNUNET_TIME_UNIT_SECONDS;
227 return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
228 ntohl (atsi->value));
233 * Update the performance information kept for the given peer.
235 * @param cp peer record to update
236 * @param atsi transport performance data
239 update_atsi (struct GSF_ConnectedPeer *cp,
240 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
242 struct GNUNET_TIME_Relative latency;
244 latency = get_latency (atsi);
245 GNUNET_LOAD_value_set_decline (cp->transmission_delay,
247 /* LATER: merge atsi into cp's performance data (if we ever care...) */
252 * Core is ready to transmit to a peer, get the message.
254 * @param cls the 'struct GSF_PeerTransmitHandle' of the message
255 * @param size number of bytes core is willing to take
256 * @param buf where to copy the message
257 * @return number of bytes copied to buf
260 peer_transmit_ready_cb (void *cls,
264 struct GSF_PeerTransmitHandle *pth = cls;
265 struct GSF_ConnectedPeer *cp;
268 if (pth->timeout_task != GNUNET_SCHEDULER_NO_TASK)
270 GNUNET_SCHEDULER_cancel (pth->timeout_task);
271 pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
274 GNUNET_CONTAINER_DLL_remove (cp->pth_head,
279 cp->ppd.last_request_times[(cp->last_request_times_off++) % MAX_QUEUE_PER_PEER] = GNUNET_TIME_absolute_get ();
280 GNUNET_assert (0 < cp->ppd.pending_queries--);
284 GNUNET_assert (0 < cp->ppd.pending_replies--);
286 GNUNET_LOAD_update (cp->ppd.transmission_delay,
287 GNUNET_TIME_absolute_get_duration (pth->request_start_time).rel_value);
288 ret = pth->gmc (pth->gmc_cls,
296 * Function called by core upon success or failure of our bandwidth reservation request.
298 * @param cls the 'struct GSF_ConnectedPeer' of the peer for which we made the request
299 * @param peer identifies the peer
300 * @param bandwidth_out available amount of outbound bandwidth
301 * @param amount set to the amount that was actually reserved or unreserved;
302 * either the full requested amount or zero (no partial reservations)
303 * @param preference current traffic preference for the given peer
306 core_reserve_callback (void *cls,
307 const struct GNUNET_PeerIdentity * peer,
308 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
312 struct GSF_ConnectedPeer *cp = cls;
318 /* failed; retry! (how did we get here!?) */
319 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
320 _("Failed to reserve bandwidth to peer `%s'\n"),
322 ip = cp->inc_preference;
323 cp->inc_preference = 0;
324 cp->irc = GNUNET_CORE_peer_change_preference (core,
326 GNUNET_TIME_UNIT_FOREVER_REL,
327 GNUNET_BANDWIDTH_VALUE_MAX,
328 GNUNET_FS_DBLOCK_SIZE,
330 &core_reserve_callback,
335 if ( (NULL != pth) &&
338 /* reservation success, try transmission now! */
339 pth->cth = GNUNET_CORE_notify_transmit_ready (core,
341 GNUNET_TIME_absolute_get_remaining (pth->timeout),
344 &peer_transmit_ready_cb,
351 * A peer connected to us. Setup the connected peer
354 * @param peer identity of peer that connected
355 * @param atsi performance data for the connection
356 * @return handle to connected peer entry
358 struct GSF_ConnectedPeer *
359 GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
360 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
362 struct GSF_ConnectedPeer *cp;
365 struct GNUNET_TIME_Relative latency;
367 cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer));
368 cp->transmission_delay = GNUNET_LOAD_value_init (latency);
369 cp->pid = GNUNET_PEER_intern (peer);
370 cp->transmission_delay = GNUNET_LOAD_value_init (0);
371 cp->irc = GNUNET_CORE_peer_change_preference (core,
373 GNUNET_TIME_UNIT_FOREVER_REL,
374 GNUNET_BANDWIDTH_VALUE_MAX,
375 GNUNET_FS_DBLOCK_SIZE,
377 &core_reserve_callback,
379 fn = get_trust_filename (peer);
380 if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) &&
381 (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust))))
382 cp->disk_trust = cp->trust = ntohl (trust);
384 GNUNET_break (GNUNET_OK ==
385 GNUNET_CONTAINER_multihashmap_put (cp_map,
388 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
389 update_atsi (cp, atsi);
390 GSF_plan_notify_new_peer_ (cp);
396 * Handle P2P "MIGRATION_STOP" message.
398 * @param cls closure, always NULL
399 * @param other the other peer involved (sender or receiver, NULL
400 * for loopback messages where we are both sender and receiver)
401 * @param message the actual message
402 * @param atsi performance information
403 * @return GNUNET_OK to keep the connection open,
404 * GNUNET_SYSERR to close it (signal serious error)
407 GSF_handle_p2p_migration_stop_ (void *cls,
408 const struct GNUNET_PeerIdentity *other,
409 const struct GNUNET_MessageHeader *message,
410 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
412 struct GSF_ConnectedPeer *cp;
413 const struct MigrationStopMessage *msm;
415 msm = (const struct MigrationStopMessage*) message;
416 cp = GNUNET_CONTAINER_multihashmap_get (cp_map,
423 cp->ppd.migration_blocked = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (msm->duration));
424 update_atsi (cp, atsi);
430 * Handle P2P "QUERY" message.
432 * @param other the other peer involved (sender or receiver, NULL
433 * for loopback messages where we are both sender and receiver)
434 * @param message the actual message
435 * @return pending request handle, NULL on error
437 struct GSF_PendingRequest *
438 GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
439 const struct GNUNET_MessageHeader *message)
443 // setup pending request
444 // track pending request to cancel it on peer disconnect (!)
446 // (actual planning & execution up to caller!)
452 * Function called if there has been a timeout trying to satisfy
453 * a transmission request.
455 * @param cls the 'struct GSF_PeerTransmitHandle' of the request
456 * @param tc scheduler context
459 peer_transmit_timeout (void *cls,
460 const struct GNUNET_SCHEDULER_TaskContext *tc)
462 struct GSF_PeerTransmitHandle *pth = cls;
463 struct GSF_ConnectedPeer *cp;
465 pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
467 GNUNET_CONTAINER_DLL_remove (cp->pth_head,
471 GNUNET_assert (0 < cp->ppd.pending_queries--);
473 GNUNET_assert (0 < cp->ppd.pending_replies--);
474 GNUNET_LOAD_update (cp->ppd.transmission_delay,
476 pth->gmc (pth->gmc_cls,
483 * Transmit a message to the given peer as soon as possible.
484 * If the peer disconnects before the transmission can happen,
485 * the callback is invoked with a 'NULL' buffer.
487 * @param peer target peer
488 * @param is_query is this a query (GNUNET_YES) or content (GNUNET_NO)
489 * @param priority how important is this request?
490 * @param timeout when does this request timeout (call gmc with error)
491 * @param size number of bytes we would like to send to the peer
492 * @param gmc function to call to get the message
493 * @param gmc_cls closure for gmc
494 * @return handle to cancel request
496 struct GSF_PeerTransmitHandle *
497 GSF_peer_transmit_ (struct GSF_ConnectedPeer *peer,
500 struct GNUNET_TIME_Relative timeout,
502 GSF_GetMessageCallback gmc,
505 struct GSF_ConnectedPeer *cp;
506 struct GSF_PeerTransmitHandle *pth;
507 struct GSF_PeerTransmitHandle *pos;
508 struct GSF_PeerTransmitHandle *prev;
509 struct GNUNET_PeerIdentity target;
513 cp = GNUNET_CONTAINER_multihashmap_get (cp_map,
515 GNUNET_assert (NULL != cp);
516 pth = GNUNET_malloc (sizeof (struct GSF_PeerTransmitHandle));
517 pth->transmission_request_start_time = GNUNET_TIME_absolute_now ();
518 pth->timeout = GNUNET_TIME_relative_to_absolute (timeout);
520 pth->gmc_cls = gmc_cls;
522 pth->is_query = is_query;
523 pth->priority = priority;
525 /* insertion sort (by priority, descending) */
528 while ( (pos != NULL) &&
529 (pos->priority > priority) )
535 GNUNET_CONTAINER_DLL_insert_head (cp->pth_head,
539 GNUNET_CONTAINER_DLL_insert_after (cp->pth_head,
543 GNUNET_PEER_resolve (cp->pid,
547 /* query, need reservation */
550 /* reservation already done! */
551 is_ready = GNUNET_YES;
552 ip = cp->inc_preference;
553 cp->inc_preference = 0;
554 cp->irc = GNUNET_CORE_peer_change_preference (core,
556 GNUNET_TIME_UNIT_FOREVER_REL,
557 GNUNET_BANDWIDTH_VALUE_MAX,
558 GNUNET_FS_DBLOCK_SIZE,
560 &core_reserve_callback,
565 /* still waiting for reservation */
566 is_ready = GNUNET_NO;
571 /* no reservation needed for content */
572 is_ready = GNUNET_YES;
576 pth->cth = GNUNET_CORE_notify_transmit_ready (core,
581 &peer_transmit_ready_cb,
583 /* pth->cth could be NULL here, that's OK, we'll try again
586 if (pth->cth == NULL)
588 /* if we're waiting for reservation OR if we could not do notify_transmit_ready,
589 install a timeout task to be on the safe side */
590 pth->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout,
591 &peer_transmit_timeout,
599 * Cancel an earlier request for transmission.
601 * @param pth request to cancel
604 GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth)
606 struct GSF_PeerTransmitHandle *pth = cls;
607 struct GSF_ConnectedPeer *cp;
609 if (pth->timeout_task != GNUNET_SCHEDULER_NO_TASK)
611 GNUNET_SCHEDULER_cancel (pth->timeout_task);
612 pth->timeout_task = GNUNET_SCHEDULER_NO_TASK;
614 if (NULL != pth->cth)
616 GNUNET_CORE_notify_transmit_ready_cancel (pth->cth);
620 GNUNET_CONTAINER_DLL_remove (cp->pth_head,
624 GNUNET_assert (0 < cp->ppd.pending_queries--);
626 GNUNET_assert (0 < cp->ppd.pending_replies--);
632 * Report on receiving a reply; update the performance record of the given peer.
634 * @param cp responding peer (will be updated)
635 * @param request_time time at which the original query was transmitted
636 * @param request_priority priority of the original request
637 * @param initiator_client local client on responsible for query (or NULL)
638 * @param initiator_peer other peer responsible for query (or NULL)
641 GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp,
642 struct GNUNET_TIME_Absolute request_time,
643 uint32_t request_priority,
644 const struct GSF_LocalClient *initiator_client,
645 const struct GSF_ConnectedPeer *initiator_peer)
647 struct GNUNET_TIME_Relative delay;
650 delay = GNUNET_TIME_absolute_get_duration (request_time);
651 cp->ppd.avg_reply_delay = (cp->ppd.avg_reply_delay * (RUNAVG_DELAY_N-1) + delay.rel_value) / RUNAVG_DELAY_N;
652 cp->ppd.avg_priority = (cp->avg_priority * (RUNAVG_DELAY_N-1) + request_priority) / RUNAVG_DELAY_N;
653 if (NULL != initiator_client)
655 cp->ppd.last_client_replies[cp->last_client_replies_woff++ % CS2P_SUCCESS_LIST_SIZE] = initiator_client;
657 else if (NULL != initiator_peer)
659 GNUNET_PEER_change_rc (cp->ppd.last_p2p_replies[cp->last_p2p_replies_woff % P2P_SUCCESS_LIST_SIZE], -1);
660 cp->ppd.last_p2p_replies[cp->last_p2p_replies_woff++ % P2P_SUCCESS_LIST_SIZE] = initiator_peer->pid;
661 GNUNET_PEER_change_rc (initiator_peer->pid, 1);
669 * Method called whenever a given peer has a status change.
672 * @param peer peer identity this notification is about
673 * @param bandwidth_in available amount of inbound bandwidth
674 * @param bandwidth_out available amount of outbound bandwidth
675 * @param timeout absolute time when this peer will time out
676 * unless we see some further activity from it
677 * @param atsi status information
680 GSF_peer_status_handler_ (void *cls,
681 const struct GNUNET_PeerIdentity *peer,
682 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
683 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
684 struct GNUNET_TIME_Absolute timeout,
685 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
687 struct GSF_ConnectedPeer *cp;
689 cp = GNUNET_CONTAINER_multihashmap_get (cp_map,
691 GNUNET_assert (NULL != cp);
692 update_atsi (cp, atsi);
697 * A peer disconnected from us. Tear down the connected peer
701 * @param peer identity of peer that connected
704 GSF_peer_disconnect_handler_ (void *cls,
705 const struct GNUNET_PeerIdentity *peer)
707 struct GSF_ConnectedPeer *cp;
708 struct GSF_PeerTransmitHandle *pth;
710 cp = GNUNET_CONTAINER_multihashmap_get (cp_map,
712 GNUNET_assert (NULL != cp);
713 GNUNET_CONTAINER_multihashmap_remove (cp_map,
718 GNUNET_CORE_peer_change_preference_cancel (cp->irc);
721 GSF_plan_notify_peer_disconnect_ (cp);
722 GNUNET_LOAD_value_free (cp->ppd.transmission_delay);
723 GNUNET_PEER_decrement_rcs (cp->ppd.last_p2p_replies, P2P_SUCCESS_LIST_SIZE);
724 while (NULL != (pth = cp->pth_head))
728 GNUNET_CORE_notify_transmit_ready_cancel (pth->th);
731 GNUNET_CONTAINER_DLL_remove (cp->pth_head,
736 GNUNET_PEER_change_rc (cp->pid, -1);
742 * Closure for 'call_iterator'.
744 struct IterationContext
747 * Function to call on each entry.
749 GSF_ConnectedPeerIterator it;
759 * Function that calls the callback for each peer.
761 * @param cls the 'struct IterationContext*'
762 * @param key identity of the peer
763 * @param value the 'struct GSF_ConnectedPeer*'
764 * @return GNUNET_YES to continue iteration
767 call_iterator (void *cls,
768 const GNUNET_HashCode *key,
771 struct IterationContext *ic = cls;
772 struct GSF_ConnectedPeer *cp = value;
775 (const struct GNUNET_PeerIdentity*) key,
783 * Iterate over all connected peers.
785 * @param it function to call for each peer
786 * @param it_cls closure for it
789 GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it,
792 struct IterationContext ic;
796 GNUNET_CONTAINER_multihashmap_iterate (cp_map,
803 * Obtain the identity of a connected peer.
805 * @param cp peer to reserve bandwidth from
806 * @param id identity to set (written to)
809 GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp,
810 struct GNUNET_PeerIdentity *id)
812 GNUNET_PEER_resolve (cp->pid,
818 * Write host-trust information to a file - flush the buffer entry!
820 * @param cls closure, not used
821 * @param key host identity
822 * @param value the 'struct GSF_ConnectedPeer' to flush
823 * @return GNUNET_OK to continue iteration
826 flush_trust (void *cls,
827 const GNUNET_HashCode *key,
830 struct GSF_ConnectedPeer *cp = value;
833 struct GNUNET_PeerIdentity pid;
835 if (cp->trust == cp->disk_trust)
836 return GNUNET_OK; /* unchanged */
837 GNUNET_PEER_resolve (cp->pid,
839 fn = get_trust_filename (&pid);
842 if ((0 != UNLINK (fn)) && (errno != ENOENT))
843 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
844 GNUNET_ERROR_TYPE_BULK, "unlink", fn);
848 trust = htonl (cp->trust);
849 if (sizeof(uint32_t) == GNUNET_DISK_fn_write (fn, &trust,
851 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE
852 | GNUNET_DISK_PERM_GROUP_READ | GNUNET_DISK_PERM_OTHER_READ))
853 cp->disk_trust = cp->trust;
861 * Notify core about a preference we have for the given peer
862 * (to allocate more resources towards it). The change will
863 * be communicated the next time we reserve bandwidth with
864 * core (not instantly).
866 * @param cp peer to reserve bandwidth from
867 * @param pref preference change
870 GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp,
873 cp->inc_preference += pref;
878 * Call this method periodically to flush trust information to disk.
880 * @param cls closure, not used
881 * @param tc task context, not used
884 cron_flush_trust (void *cls,
885 const struct GNUNET_SCHEDULER_TaskContext *tc)
890 GNUNET_CONTAINER_multihashmap_iterate (cp_map,
895 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
897 GNUNET_SCHEDULER_add_delayed (TRUST_FLUSH_FREQ,
904 * Initialize peer management subsystem.
906 * @param cfg configuration to use
909 GSF_connected_peer_init_ (struct GNUNET_CONFIGURATION_Handle *cfg)
911 cp_map = GNUNET_CONTAINER_multihashmap_create (128);
912 GNUNET_assert (GNUNET_OK ==
913 GNUNET_CONFIGURATION_get_value_filename (cfg,
917 GNUNET_DISK_directory_create (trustDirectory);
918 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH,
919 &cron_flush_trust, NULL);
924 * Iterator to free peer entries.
926 * @param cls closure, unused
927 * @param key current key code
928 * @param value value in the hash map (peer entry)
929 * @return GNUNET_YES (we should continue to iterate)
932 clean_peer (void *cls,
933 const GNUNET_HashCode * key,
936 GSF_peer_disconnect_handler_ (NULL,
937 (const struct GNUNET_PeerIdentity*) key);
943 * Shutdown peer management subsystem.
946 GSF_connected_peer_done_ ()
948 cron_flush_trust (NULL, NULL);
949 GNUNET_CONTAINER_multihashmap_iterate (cp_map,
952 GNUNET_CONTAINER_multihashmap_destroy (cp_map);
954 GNUNET_free (trustDirectory);
955 trustDirectory = NULL;
960 * Iterator to remove references to LC entry.
962 * @param the 'struct GSF_LocalClient*' to look for
963 * @param key current key code
964 * @param value value in the hash map (peer entry)
965 * @return GNUNET_YES (we should continue to iterate)
968 clean_peer (void *cls,
969 const GNUNET_HashCode * key,
972 const struct GSF_LocalClient *lc = cls;
973 struct GSF_ConnectedPeer *cp = value;
976 for (i=0;i<CS2P_SUCCESS_LIST_SIZE;i++)
977 if (cp->ppd.last_client_replies[i] == lc)
978 cp->ppd.last_client_replies[i] = NULL;
984 * Notification that a local client disconnected. Clean up all of our
985 * references to the given handle.
987 * @param lc handle to the local client (henceforth invalid)
990 GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc)
992 GNUNET_CONTAINER_multihashmap_iterate (cp_map,
998 /* end of gnunet-service-fs_cp.c */