API to handle 'connected peers'. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_load_lib.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_cp.h"
#include "gnunet-service-fs_pe.h"
#include "gnunet-service-fs_pr.h"
#include "gnunet-service-fs_push.h"
#include "gnunet_peerstore_service.h"
Go to the source code of this file.
Data Structures | |
struct | GSF_PeerTransmitHandle |
Handle to cancel a transmission request. More... | |
struct | GSF_DelayedHandle |
Handle for an entry in our delay list. More... | |
struct | PeerRequest |
Information per peer and request. More... | |
struct | GSF_ConnectedPeer |
A connected peer. More... | |
struct | TestExistClosure |
Closure for test_exist_cb(). More... | |
struct | IterationContext |
Closure for call_iterator(). More... | |
Macros | |
#define | RUNAVG_DELAY_N 16 |
Ratio for moving average delay calculation. More... | |
#define | RESPECT_FLUSH_FREQ |
How often do we flush respect values to disk? More... | |
#define | REPLY_TIMEOUT |
After how long do we discard a reply? More... | |
#define | INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC. More... | |
#define | N ((double) 128.0) |
Functions | |
void | GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id, struct GNUNET_TIME_Relative latency) |
Update the latency information kept for the given peer. More... | |
struct GSF_PeerPerformanceData * | GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp) |
Return the performance data record for the given peer. More... | |
static void | peer_transmit (struct GSF_ConnectedPeer *cp) |
Core is ready to transmit to a peer, get the message. More... | |
static void | schedule_transmission (struct GSF_PeerTransmitHandle *pth) |
If ready (bandwidth reserved), try to schedule transmission via core for the given handle. More... | |
static void | peer_respect_cb (void *cls, const struct GNUNET_PEERSTORE_Record *record, const char *emsg) |
Function called by PEERSTORE with peer respect record. More... | |
static int | consider_peer_for_forwarding (void *cls, const struct GNUNET_HashCode *key, struct GSF_PendingRequest *pr) |
Function called for each pending request whenever a new peer connects, giving us a chance to decide about submitting the existing request to the new peer. More... | |
void * | GSF_peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq) |
A peer connected to us. More... | |
static void | revive_migration (void *cls) |
It may be time to re-start migrating content to this peer. More... | |
struct GSF_ConnectedPeer * | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer) |
Get a handle for a connected peer. More... | |
void | handle_p2p_migration_stop (void *cls, const struct MigrationStopMessage *msm) |
Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message. More... | |
static void | free_pending_request (struct PeerRequest *peerreq) |
Free resources associated with the given peer request. More... | |
static int | cancel_pending_request (void *cls, const struct GNUNET_HashCode *query, void *value) |
Cancel all requests associated with the peer. More... | |
static void | peer_request_destroy (void *cls) |
Free the given request. More... | |
static void | transmit_delayed_now (void *cls) |
The artificial delay is over, transmit the message now. More... | |
static struct GNUNET_TIME_Relative | get_randomized_delay () |
Get the randomized delay a response should be subjected to. More... | |
static void | handle_p2p_reply (void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute last_transmission, enum GNUNET_BLOCK_Type type, const void *data, size_t data_len) |
Handle a reply to a pending request. More... | |
static int | change_peer_respect (struct GSF_ConnectedPeer *cp, int value) |
Increase the peer's respect by a value. More... | |
static int32_t | bound_priority (uint32_t prio_in, struct GSF_ConnectedPeer *cp) |
We've received a request with the specified priority. More... | |
static int32_t | bound_ttl (int32_t ttl_in, uint32_t prio) |
The priority level imposes a bound on the maximum value for the ttl that can be requested. More... | |
static int | test_exist_cb (void *cls, const struct GNUNET_HashCode *hc, void *value) |
Test if the query already exists. More... | |
void | handle_p2p_get (void *cls, const struct GetMessage *gm) |
Handle P2P "QUERY" message. More... | |
void | GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env) |
Transmit a message to the given peer as soon as possible. More... | |
void | GSF_peer_update_performance_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute request_time, uint32_t request_priority) |
Report on receiving a reply; update the performance record of the given peer. More... | |
void | GSF_peer_update_responder_client_ (struct GSF_ConnectedPeer *cp, struct GSF_LocalClient *initiator_client) |
Report on receiving a reply in response to an initiating client. More... | |
void | GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, const struct GSF_ConnectedPeer *initiator_peer) |
Report on receiving a reply in response to an initiating peer. More... | |
static int | flush_respect (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Write peer-respect information to a file - flush the buffer entry! More... | |
void | GSF_peer_disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls) |
A peer disconnected from us. More... | |
static int | call_iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Function that calls the callback for each peer. More... | |
void | GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls) |
Iterate over all connected peers. More... | |
void | GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp, struct GNUNET_PeerIdentity *id) |
Obtain the identity of a connected peer. More... | |
const struct GNUNET_PeerIdentity * | GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp) |
Obtain the identity of a connected peer. More... | |
void | GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp, struct GNUNET_TIME_Absolute block_time) |
Ask a peer to stop migrating data to us until the given point in time. More... | |
void | GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp, uint64_t pref) |
Notify core about a preference we have for the given peer (to allocate more resources towards it). More... | |
static void | cron_flush_respect (void *cls) |
Call this method periodically to flush respect information to disk. More... | |
void | GSF_connected_peer_init_ () |
Initialize peer management subsystem. More... | |
void | GSF_connected_peer_done_ () |
Shutdown peer management subsystem. More... | |
static int | clean_local_client (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Iterator to remove references to LC entry. More... | |
void | GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc) |
Notification that a local client disconnected. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | cp_map |
Map from peer identities to struct GSF_ConnectPeer entries. More... | |
static struct GNUNET_PEERSTORE_Handle * | peerstore |
Handle to peerstore service. More... | |
static struct GNUNET_SCHEDULER_Task * | fr_task |
Task used to flush respect values to disk. More... | |
API to handle 'connected peers'.
Definition in file gnunet-service-fs_cp.c.
#define RUNAVG_DELAY_N 16 |
Ratio for moving average delay calculation.
The previous average goes in with a factor of (n-1) into the calculation. Must be > 0.
Definition at line 41 of file gnunet-service-fs_cp.c.
#define RESPECT_FLUSH_FREQ |
How often do we flush respect values to disk?
Definition at line 46 of file gnunet-service-fs_cp.c.
#define REPLY_TIMEOUT |
After how long do we discard a reply?
Definition at line 52 of file gnunet-service-fs_cp.c.
#define INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC.
Definition at line 58 of file gnunet-service-fs_cp.c.
#define N ((double) 128.0) |
void GSF_update_peer_latency_ | ( | const struct GNUNET_PeerIdentity * | id, |
struct GNUNET_TIME_Relative | latency | ||
) |
Update the latency information kept for the given peer.
id | peer record to update |
latency | current latency value |
Definition at line 286 of file gnunet-service-fs_cp.c.
References GNUNET_LOAD_value_set_decline(), GSF_peer_get_(), GSF_ConnectedPeer::ppd, and GSF_PeerPerformanceData::transmission_delay.
struct GSF_PeerPerformanceData * GSF_get_peer_performance_data_ | ( | struct GSF_ConnectedPeer * | cp | ) |
Return the performance data record for the given peer.
cp | peer to query |
Definition at line 306 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::ppd.
Referenced by handle_p2p_put(), put_migration_continuation(), score_content(), and transmit_content().
|
static |
Core is ready to transmit to a peer, get the message.
cp | which peer to send a message to |
Definition at line 347 of file gnunet-service-fs_cp.c.
References GSF_PeerTransmitHandle::cp, GSF_PeerTransmitHandle::env, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_LOAD_update(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, GSF_PeerTransmitHandle::is_query, GSF_PeerPerformanceData::last_request_times, GSF_ConnectedPeer::last_request_times_off, MAX_QUEUE_PER_PEER, GSF_ConnectedPeer::mq, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, GNUNET_TIME_Relative::rel_value_us, schedule_transmission(), GSF_PeerPerformanceData::transmission_delay, and GSF_PeerTransmitHandle::transmission_request_start_time.
Referenced by schedule_transmission().
|
static |
If ready (bandwidth reserved), try to schedule transmission via core for the given handle.
pth | transmission handle to schedule |
Definition at line 328 of file gnunet-service-fs_cp.c.
References GSF_PeerTransmitHandle::cp, GNUNET_assert, GNUNET_PEER_resolve(), peer_transmit(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
Referenced by GSF_peer_transmit_(), and peer_transmit().
|
static |
Function called by PEERSTORE with peer respect record.
cls | handle to connected peer entry |
record | peerstore record information |
emsg | error message, or NULL if no errors |
Definition at line 390 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::disk_respect, GNUNET_assert, GNUNET_PEERSTORE_iteration_next(), GNUNET_PEERSTORE_iteration_stop(), GSF_push_start_(), GSF_ConnectedPeer::ppd, record(), GSF_PeerPerformanceData::respect, and GSF_ConnectedPeer::respect_iterate_req.
Referenced by GSF_peer_connect_handler().
|
static |
Function called for each pending request whenever a new peer connects, giving us a chance to decide about submitting the existing request to the new peer.
cls | the struct GSF_ConnectedPeer of the new peer |
key | query for the request |
pr | handle to the pending request |
Definition at line 430 of file gnunet-service-fs_cp.c.
References gettext_noop, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSF_connected_peer_get_identity_(), GSF_pending_request_test_active_(), GSF_pending_request_test_target_(), GSF_plan_add_(), GSF_stats, and pid.
Referenced by GSF_peer_connect_handler().
void * GSF_peer_connect_handler | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
struct GNUNET_MQ_Handle * | mq | ||
) |
A peer connected to us.
Setup the connected peer records.
cls | NULL |
peer | identity of peer that connected |
mq | message queue for talking to peer |
Definition at line 456 of file gnunet-service-fs_cp.c.
References consider_peer_for_forwarding(), cp_map, gettext_noop, GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_LOAD_value_init(), GNUNET_log, GNUNET_memcmp, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_PEERSTORE_iteration_start(), GNUNET_STATISTICS_set(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, GSF_connected_peer_get_identity2_(), GSF_iterate_pending_requests_(), GSF_my_id, GSF_stats, mq, GSF_ConnectedPeer::mq, GSF_PeerPerformanceData::peer, peer_respect_cb(), peerstore, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.
Referenced by main_init().
|
static |
It may be time to re-start migrating content to this peer.
Check, and if so, restart migration.
cls | the struct GSF_ConnectedPeer |
Definition at line 507 of file gnunet-service-fs_cp.c.
References GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_absolute_get_remaining(), GSF_push_start_(), GSF_ConnectedPeer::mig_revive_task, GSF_PeerPerformanceData::migration_blocked_until, GSF_ConnectedPeer::ppd, GNUNET_TIME_Relative::rel_value_us, and revive_migration().
Referenced by handle_p2p_migration_stop(), and revive_migration().
struct GSF_ConnectedPeer * GSF_peer_get_ | ( | const struct GNUNET_PeerIdentity * | peer | ) |
Get a handle for a connected peer.
peer | peer's identity |
Definition at line 526 of file gnunet-service-fs_cp.c.
References cp_map, and GNUNET_CONTAINER_multipeermap_get().
Referenced by GSF_update_peer_latency_(), handle_p2p_get(), and put_migration_continuation().
void handle_p2p_migration_stop | ( | void * | cls, |
const struct MigrationStopMessage * | msm | ||
) |
Handle P2P GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP message.
cls | closure, the struct GSF_ConnectedPeer |
msm | the actual message |
Definition at line 541 of file gnunet-service-fs_cp.c.
References _, MigrationStopMessage::duration, gettext_noop, GNUNET_ERROR_TYPE_INFO, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_ntoh(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, GSF_push_stop_(), GSF_stats, GSF_ConnectedPeer::mig_revive_task, GSF_PeerPerformanceData::migration_blocked_until, GSF_PeerPerformanceData::peer, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::respect_iterate_req, and revive_migration().
|
static |
Free resources associated with the given peer request.
peerreq | request to free |
Definition at line 573 of file gnunet-service-fs_cp.c.
References PeerRequest::cp, gettext_noop, GNUNET_break, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_pending_request_get_data_(), GSF_stats, PeerRequest::kill_task, PeerRequest::pr, GSF_PendingRequestData::query, and GSF_ConnectedPeer::request_map.
Referenced by cancel_pending_request(), handle_p2p_reply(), and test_exist_cb().
|
static |
Cancel all requests associated with the peer.
cls | unused |
query | hash code of the request |
value | the struct GSF_PendingRequest |
Definition at line 605 of file gnunet-service-fs_cp.c.
References free_pending_request(), GNUNET_NO, GNUNET_OK, GSF_pending_request_cancel_(), PeerRequest::pr, and value.
Referenced by GSF_peer_disconnect_handler(), and peer_request_destroy().
|
static |
Free the given request.
cls | the request to free |
Definition at line 625 of file gnunet-service-fs_cp.c.
References cancel_pending_request(), GSF_pending_request_get_data_(), PeerRequest::kill_task, PeerRequest::pr, and GSF_PendingRequestData::query.
Referenced by handle_p2p_reply().
|
static |
The artificial delay is over, transmit the message now.
cls | the struct GSF_DelayedHandle with the message |
Definition at line 645 of file gnunet-service-fs_cp.c.
References GSF_DelayedHandle::cp, GSF_ConnectedPeer::delay_queue_size, GSF_ConnectedPeer::delayed_head, GSF_ConnectedPeer::delayed_tail, GSF_DelayedHandle::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, and GSF_peer_transmit_().
Referenced by handle_p2p_reply().
|
static |
Get the randomized delay a response should be subjected to.
Definition at line 668 of file gnunet-service-fs_cp.c.
References gettext_noop, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MILLISECONDS, GSF_avg_latency, GSF_stats, GNUNET_TIME_Relative::rel_value_us, and ret.
Referenced by handle_p2p_reply().
|
static |
Handle a reply to a pending request.
Also called if a request expires (then with data == NULL). The handler may be called many times (depending on the request type), but will not be called during or after a call to GSF_pending_request_cancel and will also not be called anymore after a call signalling expiration.
cls | struct PeerRequest this is an answer for |
eval | evaluation of the result |
pr | handle to the original pending request |
reply_anonymity_level | anonymity level for the reply, UINT32_MAX for "unknown" |
expiration | when does data expire? |
last_transmission | when did we last transmit a request for this block |
type | type of the block |
data | response data, NULL on request expiration |
data_len | number of bytes in data |
Definition at line 706 of file gnunet-service-fs_cp.c.
References GSF_DelayedHandle::cp, PeerRequest::cp, data, GSF_ConnectedPeer::delay_queue_size, GSF_DelayedHandle::delay_task, GSF_ConnectedPeer::delayed_head, GSF_ConnectedPeer::delayed_tail, env, GSF_DelayedHandle::env, expiration, free_pending_request(), get_randomized_delay(), GNUNET_assert, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_msg_extra, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GSF_cover_content_count, GSF_enable_randomized_delays, GSF_peer_transmit_(), GSF_pending_request_get_data_(), GSF_stats, PeerRequest::kill_task, GSF_DelayedHandle::msize, peer_request_destroy(), pm, PeerRequest::pr, GSF_PendingRequestData::query, transmit_delayed_now(), type, and GSF_PendingRequestData::type.
Referenced by handle_p2p_get().
|
static |
Increase the peer's respect by a value.
cp | which peer to change the respect value on |
value | is the int value by which the peer's credit is to be increased or decreased |
Definition at line 825 of file gnunet-service-fs_cp.c.
References GSF_DelayedHandle::cp, GNUNET_assert, GSF_ConnectedPeer::ppd, GSF_PeerPerformanceData::respect, and value.
Referenced by bound_priority().
|
static |
We've received a request with the specified priority.
Bound it according to how much we respect the given peer.
prio_in | requested priority |
cp | the peer making the request |
Definition at line 863 of file gnunet-service-fs_cp.c.
References change_peer_respect(), GSF_DelayedHandle::cp, gettext_noop, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, GSF_current_priorities, GSF_stats, GSF_test_get_load_too_high_(), N, and ret.
Referenced by handle_p2p_get().
|
static |
The priority level imposes a bound on the maximum value for the ttl that can be requested.
ttl_in | requested ttl |
prio | given priority |
Definition at line 931 of file gnunet-service-fs_cp.c.
References TTL_DECREMENT.
Referenced by handle_p2p_get().
|
static |
Test if the query already exists.
If so, merge it, otherwise keep finished
at GNUNET_NO.
cls | our struct TestExistClosure |
hc | the key of the query |
value | the existing struct PeerRequest . |
Definition at line 987 of file gnunet-service-fs_cp.c.
References GNUNET_TIME_Absolute::abs_value_us, TestExistClosure::finished, free_pending_request(), gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_pending_request_cancel_(), GSF_pending_request_get_data_(), GSF_stats, PeerRequest::pr, TestExistClosure::priority, GSF_PendingRequestData::priority, TestExistClosure::ttl, GSF_PendingRequestData::ttl, TestExistClosure::type, GSF_PendingRequestData::type, and value.
Referenced by handle_p2p_get().
void handle_p2p_get | ( | void * | cls, |
const struct GetMessage * | gm | ||
) |
Handle P2P "QUERY" message.
Creates the pending request entry and sets up all of the data structures to that we will process replies properly. Does not initiate forwarding or local database lookups.
cls | the other peer involved (sender of the message) |
gm | the GET message |
Definition at line 1033 of file gnunet-service-fs_cp.c.
References bound_priority(), bound_ttl(), PeerRequest::cp, GSF_ConnectedPeer::delay_queue_size, TestExistClosure::finished, GET_MESSAGE_BIT_RETURN_TO, GET_MESSAGE_BIT_TRANSMIT_TO, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONSTANTS_MAX_CORK_DELAY, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_LOAD_get_average(), GNUNET_LOAD_get_load(), GNUNET_log, GNUNET_MQ_get_length(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PEER_intern(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_consider_forwarding(), GSF_cover_query_count, GSF_local_lookup_(), GSF_peer_get_(), GSF_pending_request_create_(), GSF_pending_request_get_data_(), GSF_PRO_DEFAULTS, GSF_PRO_FORWARD_ONLY, GSF_rt_entry_lifetime, GSF_stats, handle_p2p_reply(), GSF_PendingRequestData::has_started, GetMessage::hash_bitmap, GetMessage::header, MAX_QUEUE_PER_PEER, GSF_ConnectedPeer::mq, options, GSF_PeerPerformanceData::peer, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, PeerRequest::pr, GetMessage::priority, TestExistClosure::priority, GetMessage::query, GSF_PendingRequestData::query, GSF_ConnectedPeer::request_map, GNUNET_MessageHeader::size, test_exist_cb(), GSF_PeerPerformanceData::transmission_delay, GetMessage::ttl, TestExistClosure::ttl, TTL_DECREMENT, GetMessage::type, and TestExistClosure::type.
void GSF_peer_transmit_ | ( | struct GSF_ConnectedPeer * | cp, |
int | is_query, | ||
uint32_t | priority, | ||
struct GNUNET_MQ_Envelope * | env | ||
) |
Transmit a message to the given peer as soon as possible.
If the peer disconnects before the transmission can happen, the callback is invoked with a NULL
buffer.
cp | target peer |
is_query | is this a query (GNUNET_YES) or content (GNUNET_NO) or neither (GNUNET_SYSERR) |
priority | how important is this request? |
env | message to send |
Definition at line 1231 of file gnunet-service-fs_cp.c.
References GSF_PeerTransmitHandle::cp, env, GSF_PeerTransmitHandle::env, GNUNET_CONTAINER_DLL_insert_after, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_YES, GSF_PeerTransmitHandle::is_query, GSF_PeerTransmitHandle::next, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_ConnectedPeer::ppd, GSF_PeerTransmitHandle::prev, GSF_PeerTransmitHandle::priority, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, schedule_transmission(), and GSF_PeerTransmitHandle::transmission_request_start_time.
Referenced by GSF_block_peer_migration_(), handle_p2p_reply(), schedule_peer_transmission(), transmit_content(), and transmit_delayed_now().
void GSF_peer_update_performance_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GNUNET_TIME_Absolute | request_time, | ||
uint32_t | request_priority | ||
) |
Report on receiving a reply; update the performance record of the given peer.
cp | responding peer (will be updated) |
request_time | time at which the original query was transmitted |
request_priority | priority of the original request |
Definition at line 1274 of file gnunet-service-fs_cp.c.
References GSF_PeerPerformanceData::avg_priority, GSF_PeerPerformanceData::avg_reply_delay, GNUNET_TIME_absolute_get_duration(), GSF_ConnectedPeer::ppd, GNUNET_TIME_Relative::rel_value_us, and RUNAVG_DELAY_N.
Referenced by update_request_performance_data().
void GSF_peer_update_responder_client_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GSF_LocalClient * | initiator_client | ||
) |
Report on receiving a reply in response to an initiating client.
Remember that this peer is good for this client.
cp | responding peer (will be updated) |
initiator_client | local client on responsible for query |
Definition at line 1298 of file gnunet-service-fs_cp.c.
References CS2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::last_client_replies, GSF_ConnectedPeer::last_client_replies_woff, and GSF_ConnectedPeer::ppd.
void GSF_peer_update_responder_peer_ | ( | struct GSF_ConnectedPeer * | cp, |
const struct GSF_ConnectedPeer * | initiator_peer | ||
) |
Report on receiving a reply in response to an initiating peer.
Remember that this peer is good for this initiating peer.
cp | responding peer (will be updated) |
initiator_peer | other peer responsible for query |
Definition at line 1314 of file gnunet-service-fs_cp.c.
References GNUNET_PEER_change_rc(), GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::last_p2p_replies_woff, P2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
|
static |
Write peer-respect information to a file - flush the buffer entry!
cls | unused |
key | peer identity |
value | the struct GSF_ConnectedPeer to flush |
Definition at line 1336 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::disk_respect, GNUNET_assert, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_PEERSTORE_store(), GNUNET_PEERSTORE_STOREOPTION_REPLACE, GNUNET_TIME_UNIT_FOREVER_ABS, peerstore, GSF_PeerPerformanceData::pid, pid, GSF_ConnectedPeer::ppd, GSF_PeerPerformanceData::respect, and value.
Referenced by cron_flush_respect(), GSF_connected_peer_done_(), and GSF_peer_disconnect_handler().
void GSF_peer_disconnect_handler | ( | void * | cls, |
const struct GNUNET_PeerIdentity * | peer, | ||
void * | internal_cls | ||
) |
A peer disconnected from us.
Tear down the connected peer record.
cls | unused |
peer | identity of peer that disconnected |
internal_cls | the corresponding struct GSF_ConnectedPeer |
Definition at line 1358 of file gnunet-service-fs_cp.c.
References cancel_pending_request(), GSF_DelayedHandle::cp, cp_map, GSF_ConnectedPeer::delay_queue_size, GSF_DelayedHandle::delay_task, GSF_ConnectedPeer::delayed_head, GSF_ConnectedPeer::delayed_tail, GSF_DelayedHandle::env, flush_respect(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_free, GNUNET_LOAD_value_free, GNUNET_MQ_discard(), GNUNET_NO, GNUNET_PEER_change_rc(), GNUNET_PEER_decrement_rcs(), GNUNET_PEERSTORE_iteration_stop(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_YES, GSF_plan_notify_peer_disconnect_(), GSF_push_stop_(), GSF_stats, GSF_PeerTransmitHandle::is_query, GSF_PeerPerformanceData::last_p2p_replies, GSF_ConnectedPeer::mig_revive_task, P2P_SUCCESS_LIST_SIZE, GSF_PeerPerformanceData::pending_queries, GSF_PeerPerformanceData::pending_replies, GSF_PeerPerformanceData::pid, GSF_ConnectedPeer::ppd, GSF_ConnectedPeer::pth_head, GSF_ConnectedPeer::pth_tail, GSF_ConnectedPeer::request_map, GSF_ConnectedPeer::respect_iterate_req, and GSF_PeerPerformanceData::transmission_delay.
Referenced by main_init().
|
static |
Function that calls the callback for each peer.
cls | the struct IterationContext * |
key | identity of the peer |
value | the struct GSF_ConnectedPeer * |
Definition at line 1457 of file gnunet-service-fs_cp.c.
References GNUNET_YES, IterationContext::it, IterationContext::it_cls, key, GSF_ConnectedPeer::ppd, and value.
Referenced by GSF_iterate_connected_peers_().
void GSF_iterate_connected_peers_ | ( | GSF_ConnectedPeerIterator | it, |
void * | it_cls | ||
) |
Iterate over all connected peers.
it | function to call for each peer |
it_cls | closure for it |
Definition at line 1472 of file gnunet-service-fs_cp.c.
References call_iterator(), cp_map, GNUNET_CONTAINER_multipeermap_iterate(), IterationContext::it, and IterationContext::it_cls.
Referenced by GSF_consider_forwarding().
void GSF_connected_peer_get_identity_ | ( | const struct GSF_ConnectedPeer * | cp, |
struct GNUNET_PeerIdentity * | id | ||
) |
Obtain the identity of a connected peer.
cp | peer to get identity of |
id | identity to set (written to) |
Definition at line 1492 of file gnunet-service-fs_cp.c.
References GNUNET_assert, GNUNET_PEER_resolve(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
Referenced by consider_peer_for_forwarding().
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_ | ( | const struct GSF_ConnectedPeer * | cp | ) |
Obtain the identity of a connected peer.
cp | peer to get identity of |
Definition at line 1507 of file gnunet-service-fs_cp.c.
References GNUNET_assert, GNUNET_PEER_resolve2(), GSF_PeerPerformanceData::pid, and GSF_ConnectedPeer::ppd.
Referenced by GSF_peer_connect_handler(), GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_push_start_(), and process_migration_content().
void GSF_block_peer_migration_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GNUNET_TIME_Absolute | block_time | ||
) |
Ask a peer to stop migrating data to us until the given point in time.
cp | peer to ask |
block_time | until when to block |
Definition at line 1522 of file gnunet-service-fs_cp.c.
References GNUNET_TIME_Absolute::abs_value_us, MigrationStopMessage::duration, env, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, GNUNET_MQ_msg, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_hton(), GNUNET_YES, GSF_peer_transmit_(), GSF_stats, GSF_ConnectedPeer::last_migration_block, and MigrationStopMessage::reserved.
Referenced by handle_p2p_put(), and put_migration_continuation().
void GSF_connected_peer_change_preference_ | ( | struct GSF_ConnectedPeer * | cp, |
uint64_t | pref | ||
) |
Notify core about a preference we have for the given peer (to allocate more resources towards it).
The change will be communicated the next time we reserve bandwidth with core (not instantly).
cp | peer to reserve bandwidth from |
pref | preference change |
Definition at line 1570 of file gnunet-service-fs_cp.c.
References GSF_ConnectedPeer::inc_preference.
Referenced by handle_p2p_put().
|
static |
Call this method periodically to flush respect information to disk.
cls | closure, not used |
Definition at line 1583 of file gnunet-service-fs_cp.c.
References cp_map, cron_flush_respect(), flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, and RESPECT_FLUSH_FREQ.
Referenced by cron_flush_respect(), and GSF_connected_peer_init_().
void GSF_connected_peer_init_ | ( | void | ) |
Initialize peer management subsystem.
Definition at line 1600 of file gnunet-service-fs_cp.c.
References cp_map, cron_flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_create(), GNUNET_PEERSTORE_connect(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_YES, GSF_cfg, and peerstore.
Referenced by run().
void GSF_connected_peer_done_ | ( | void | ) |
Shutdown peer management subsystem.
Definition at line 1613 of file gnunet-service-fs_cp.c.
References cp_map, flush_respect(), fr_task, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_PEERSTORE_disconnect(), GNUNET_SCHEDULER_cancel(), and peerstore.
Referenced by shutdown_task().
|
static |
Iterator to remove references to LC entry.
cls | the struct GSF_LocalClient * to look for |
key | current key code |
value | value in the hash map (peer entry) |
Definition at line 1635 of file gnunet-service-fs_cp.c.
References CS2P_SUCCESS_LIST_SIZE, GNUNET_YES, GSF_PeerPerformanceData::last_client_replies, GSF_ConnectedPeer::ppd, and value.
Referenced by GSF_handle_local_client_disconnect_().
void GSF_handle_local_client_disconnect_ | ( | const struct GSF_LocalClient * | lc | ) |
Notification that a local client disconnected.
Clean up all of our references to the given handle.
lc | handle to the local client (henceforth invalid) |
Definition at line 1657 of file gnunet-service-fs_cp.c.
References clean_local_client(), cp_map, and GNUNET_CONTAINER_multipeermap_iterate().
|
static |
Map from peer identities to struct GSF_ConnectPeer
entries.
Definition at line 266 of file gnunet-service-fs_cp.c.
Referenced by cron_flush_respect(), GSF_connected_peer_done_(), GSF_connected_peer_init_(), GSF_handle_local_client_disconnect_(), GSF_iterate_connected_peers_(), GSF_peer_connect_handler(), GSF_peer_disconnect_handler(), and GSF_peer_get_().
|
static |
Handle to peerstore service.
Definition at line 271 of file gnunet-service-fs_cp.c.
Referenced by flush_respect(), GSF_connected_peer_done_(), GSF_connected_peer_init_(), and GSF_peer_connect_handler().
|
static |
Task used to flush respect values to disk.
Definition at line 276 of file gnunet-service-fs_cp.c.
Referenced by cron_flush_respect(), GSF_connected_peer_done_(), and GSF_connected_peer_init_().