/*
This file is part of GNUnet.
- (C) 2009-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009-2014 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
/**
* ID of our task that we use to age the cover counters.
*/
-static GNUNET_SCHEDULER_TaskIdentifier cover_age_task;
+static struct GNUNET_SCHEDULER_Task * cover_age_task;
/**
* Datastore 'GET' load tracking.
* Task that periodically ages our cover traffic statistics.
*
* @param cls unused closure
- * @param tc task context
*/
static void
-age_cover_counters (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+age_cover_counters (void *cls)
{
GSF_cover_content_count = (GSF_cover_content_count * 15) / 16;
GSF_cover_query_count = (GSF_cover_query_count * 15) / 16;
cover_age_task =
- GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters,
+ GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY,
+ &age_cover_counters,
NULL);
}
/**
* We've received peer performance information. Update
* our running average for the P2P latency.
-*
+ *
* @param cls closure
* @param address the address
* @param active is this address in active use
* @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection
- * @param ats performance data for the address (as far as known)
- * @param ats_count number of performance records in @a ats
+ * @param prop performance data for the address (as far as known)
*/
static void
update_latencies (void *cls,
int active,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
- const struct GNUNET_ATS_Information *ats,
- uint32_t ats_count)
+ const struct GNUNET_ATS_Properties *prop)
{
- unsigned int i;
- struct GNUNET_TIME_Relative latency;
-
if (NULL == address)
{
/* ATS service temporarily disconnected */
if (GNUNET_YES != active)
return;
- for (i = 0; i < ats_count; i++)
- {
- if (GNUNET_ATS_QUALITY_NET_DELAY != ntohl (ats[i].type))
- continue;
- latency.rel_value_us = ntohl (ats[i].value);
- GSF_update_peer_latency_ (&address->peer,
- latency);
- GSF_avg_latency.rel_value_us =
- (GSF_avg_latency.rel_value_us * 31 +
- GNUNET_MIN (5000, ntohl (ats[i].value))) / 32;
- GNUNET_STATISTICS_set (GSF_stats,
- gettext_noop
- ("# running average P2P latency (ms)"),
- GSF_avg_latency.rel_value_us / 1000LL, GNUNET_NO);
- break;
- }
+ GSF_update_peer_latency_ (&address->peer,
+ prop->delay);
+ GSF_avg_latency.rel_value_us =
+ (GSF_avg_latency.rel_value_us * 31 +
+ GNUNET_MIN (5000, prop->delay.rel_value_us)) / 32;
+ GNUNET_STATISTICS_set (GSF_stats,
+ gettext_noop ("# running average P2P latency (ms)"),
+ GSF_avg_latency.rel_value_us / 1000LL,
+ GNUNET_NO);
}
{
if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
return; /* we're done... */
- GSF_iterate_connected_peers_ (&consider_request_for_forwarding, pr);
+ if (GNUNET_YES !=
+ GSF_pending_request_test_active_ (pr))
+ return; /* request is not actually active, skip! */
+ GSF_iterate_connected_peers_ (&consider_request_for_forwarding,
+ pr);
}
{
struct GSF_PendingRequest *pr;
- pr = GSF_handle_p2p_query_ (other, message);
+ pr = GSF_handle_p2p_query_ (other,
+ message);
if (NULL == pr)
- return GNUNET_SYSERR;
+ return GNUNET_OK; /* exists, identical to existing request, or malformed */
GSF_pending_request_get_data_ (pr)->has_started = GNUNET_YES;
GSF_local_lookup_ (pr,
- &consider_forwarding, NULL);
+ &consider_forwarding,
+ NULL);
return GNUNET_OK;
}
/**
- * Handle START_SEARCH-message (search request from client).
+ * Handle #GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request
+ * from client).
*
* @param cls closure
* @param client identification of the client
* Task run during shutdown.
*
* @param cls unused
- * @param tc unused
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
GSF_cadet_stop_client ();
GSF_cadet_stop_server ();
block_cfg = NULL;
GNUNET_STATISTICS_destroy (GSF_stats, GNUNET_NO);
GSF_stats = NULL;
- if (GNUNET_SCHEDULER_NO_TASK != cover_age_task)
+ if (NULL != cover_age_task)
{
GNUNET_SCHEDULER_cancel (cover_age_task);
- cover_age_task = GNUNET_SCHEDULER_NO_TASK;
+ cover_age_task = NULL;
}
GNUNET_FS_indexing_done ();
GNUNET_LOAD_value_free (datastore_get_load);
* peer connects, giving us a chance to decide about submitting
* the existing request to the new peer.
*
- * @param cls the 'struct GSF_ConnectedPeer' of the new peer
+ * @param cls the `struct GSF_ConnectedPeer` of the new peer
* @param key query for the request
* @param pr handle to the pending request
* @return #GNUNET_YES to continue to iterate
struct GSF_ConnectedPeer *cp = cls;
struct GNUNET_PeerIdentity pid;
+ if (GNUNET_YES !=
+ GSF_pending_request_test_active_ (pr))
+ return GNUNET_YES; /* request is not actually active, skip! */
GSF_connected_peer_get_identity_ (cp, &pid);
- if (GNUNET_YES != GSF_pending_request_test_target_ (pr, &pid))
+ if (GNUNET_YES !=
+ GSF_pending_request_test_target_ (pr, &pid))
{
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop ("# Loopback routes suppressed"), 1,
+ gettext_noop ("# Loopback routes suppressed"),
+ 1,
GNUNET_NO);
return GNUNET_YES;
}
* @param cp handle to the newly created connected peer record
*/
static void
-connected_peer_cb (void *cls, struct GSF_ConnectedPeer *cp)
+connected_peer_cb (void *cls,
+ struct GSF_ConnectedPeer *cp)
{
if (NULL == cp)
return;
- GSF_iterate_pending_requests_ (&consider_peer_for_forwarding, cp);
+ GSF_iterate_pending_requests_ (&consider_peer_for_forwarding,
+ cp);
}
peer_connect_handler (void *cls,
const struct GNUNET_PeerIdentity *peer)
{
- if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_id,
- peer))
+ if (0 ==
+ GNUNET_CRYPTO_cmp_peer_identity (&my_id,
+ peer))
return;
GSF_peer_connect_handler_ (peer,
&connected_peer_cb,
GNUNET_CRYPTO_eddsa_key_get_public (pk,
&my_id.public_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "I am peer %s\n",
+ GNUNET_i2s (&my_id));
GSF_core
= GNUNET_CORE_connect (GSF_cfg, NULL,
&peer_init_handler,
NULL);
GNUNET_SERVER_add_handlers (server, handlers);
cover_age_task =
- GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters,
+ GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY,
+ &age_cover_counters,
NULL);
datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
GSF_cadet_start_server ();
GSF_cadet_start_client ();
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
return GNUNET_OK;
}
(GNUNET_OK != main_init (server, cfg)))
{
GNUNET_SCHEDULER_shutdown ();
- shutdown_task (NULL, NULL);
+ shutdown_task (NULL);
return;
}
}