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.
*/
-
/**
* @file fs/gnunet-service-fs_cp.c
* @brief API to handle 'connected peers'
uint32_t disk_respect;
/**
- * Which offset in "last_p2p_replies" will be updated next?
+ * Which offset in @e last_p2p_replies will be updated next?
* (we go round-robin).
*/
unsigned int last_p2p_replies_woff;
/**
- * Which offset in "last_client_replies" will be updated next?
+ * Which offset in @e last_client_replies will be updated next?
* (we go round-robin).
*/
unsigned int last_client_replies_woff;
/**
- * Current offset into 'last_request_times' ring buffer.
+ * Current offset into @e last_request_times ring buffer.
*/
unsigned int last_request_times_off;
/**
- * Map from peer identities to 'struct GSF_ConnectPeer' entries.
+ * Map from peer identities to `struct GSF_ConnectPeer` entries.
*/
static struct GNUNET_CONTAINER_MultiPeerMap *cp_map;
cp = GSF_peer_get_ (id);
if (NULL == cp)
return; /* we're not yet connected at the core level, ignore */
- GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay, latency);
+ GNUNET_LOAD_value_set_decline (cp->ppd.transmission_delay,
+ latency);
}
cp->inc_preference = 0;
}
- if ((GNUNET_YES == pth->is_query) && (GNUNET_YES != pth->was_reserved))
+ if ( (GNUNET_YES == pth->is_query) &&
+ (GNUNET_YES != pth->was_reserved) )
{
/* query, need reservation */
if (GNUNET_YES != cp->did_reserve)
cp->did_reserve = GNUNET_NO;
/* reservation already done! */
pth->was_reserved = GNUNET_YES;
- cp->rc =
- GNUNET_ATS_reserve_bandwidth (GSF_ats, &target, DBLOCK_SIZE,
- &ats_reserve_callback, cp);
+ cp->rc = GNUNET_ATS_reserve_bandwidth (GSF_ats,
+ &target,
+ DBLOCK_SIZE,
+ &ats_reserve_callback,
+ cp);
return;
}
GNUNET_assert (NULL == cp->cth);
GNUNET_CORE_notify_transmit_ready (GSF_core,
GNUNET_YES,
GNUNET_CORE_PRIO_BACKGROUND,
- GNUNET_TIME_absolute_get_remaining
- (pth->timeout),
+ GNUNET_TIME_absolute_get_remaining (pth->timeout),
&target,
pth->size,
&peer_transmit_ready_cb, cp);
{
cp->ppd.last_request_times[(cp->last_request_times_off++) %
MAX_QUEUE_PER_PEER] =
- GNUNET_TIME_absolute_get ();
+ GNUNET_TIME_absolute_get ();
GNUNET_assert (0 < cp->ppd.pending_queries--);
}
else if (GNUNET_NO == pth->is_query)
if (0 == amount)
{
cp->rc_delay_task =
- GNUNET_SCHEDULER_add_delayed (res_delay, &retry_reservation, cp);
+ GNUNET_SCHEDULER_add_delayed (res_delay,
+ &retry_reservation,
+ cp);
return;
}
cp->did_reserve = GNUNET_YES;
pth = cp->pth_head;
- if ((NULL != pth) && (NULL == cp->cth) && (0 == cp->cth_in_progress))
+ if ( (NULL != pth) &&
+ (NULL == cp->cth) &&
+ (0 == cp->cth_in_progress) )
{
/* reservation success, try transmission now! */
cp->cth_in_progress++;
cp->cth =
- GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES,
+ GNUNET_CORE_notify_transmit_ready (GSF_core,
+ GNUNET_YES,
GNUNET_CORE_PRIO_BACKGROUND,
- GNUNET_TIME_absolute_get_remaining
- (pth->timeout), peer, pth->size,
- &peer_transmit_ready_cb, cp);
+ GNUNET_TIME_absolute_get_remaining (pth->timeout),
+ peer,
+ pth->size,
+ &peer_transmit_ready_cb,
+ cp);
GNUNET_assert (NULL != cp->cth);
GNUNET_assert (0 < cp->cth_in_progress--);
}
{
struct GSF_ConnectedPeer *cp = cls;
+ GNUNET_assert (NULL != cp->respect_iterate_req);
cp->respect_iterate_req = NULL;
if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size))
cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value);
GNUNET_i2s (other),
GNUNET_STRINGS_relative_time_to_string (bt, GNUNET_YES));
cp->ppd.migration_blocked_until = GNUNET_TIME_relative_to_absolute (bt);
- if (NULL == cp->mig_revive_task)
+ if ( (NULL == cp->mig_revive_task) &&
+ (NULL == cp->respect_iterate_req) )
{
GSF_push_stop_ (cp);
cp->mig_revive_task =
size = ntohs (pm->header.size);
memcpy (buf, pm, size);
GNUNET_STATISTICS_update (GSF_stats,
- gettext_noop
- ("# replies transmitted to other peers"), 1,
+ gettext_noop ("# replies transmitted to other peers"),
+ 1,
GNUNET_NO);
}
else
{
size = 0;
- GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# replies dropped"), 1,
+ GNUNET_STATISTICS_update (GSF_stats,
+ gettext_noop ("# replies dropped"),
+ 1,
GNUNET_NO);
}
GNUNET_free (pm);
GNUNET_NO);
return NULL;
}
- if (cp->ppd.pending_replies + cp->delay_queue_size > 128)
+ if (cp->ppd.pending_replies + cp->delay_queue_size > MAX_QUEUE_PER_PEER)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' has too many replies queued already. Dropping query.\n",
ttl -= ttl_decrement;
/* test if the request already exists */
- peerreq = GNUNET_CONTAINER_multihashmap_get (cp->request_map, &gm->query);
- if (peerreq != NULL)
+ peerreq = GNUNET_CONTAINER_multihashmap_get (cp->request_map,
+ &gm->query);
+ if (NULL != peerreq)
{
pr = peerreq->pr;
prd = GSF_pending_request_get_data_ (pr);
peerreq = GNUNET_new (struct PeerRequest);
peerreq->cp = cp;
- pr = GSF_pending_request_create_ (options, type, &gm->query,
+ pr = GSF_pending_request_create_ (options,
+ type,
+ &gm->query,
target,
- (bfsize >
- 0) ? (const char *) &opt[bits] : NULL,
- bfsize, ntohl (gm->filter_mutator),
- 1 /* anonymity */ ,
- (uint32_t) priority, ttl, spid, GNUNET_PEER_intern (other), NULL, 0, /* replies_seen */
+ (bfsize > 0)
+ ? (const char *) &opt[bits]
+ : NULL,
+ bfsize,
+ ntohl (gm->filter_mutator),
+ 1 /* anonymity */,
+ (uint32_t) priority,
+ ttl,
+ spid,
+ GNUNET_PEER_intern (other),
+ NULL, 0, /* replies_seen */
&handle_p2p_reply, peerreq);
GNUNET_assert (NULL != pr);
peerreq->pr = pr;
* @param tc task context, not used
*/
static void
-cron_flush_respect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+cron_flush_respect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-
if (NULL == cp_map)
return;
- GNUNET_CONTAINER_multipeermap_iterate (cp_map, &flush_respect, NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (cp_map,
+ &flush_respect, NULL);
if (NULL == tc)
return;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
GSF_connected_peer_done_ ()
{
cron_flush_respect (NULL, NULL);
- GNUNET_CONTAINER_multipeermap_iterate (cp_map, &clean_peer, NULL);
+ GNUNET_CONTAINER_multipeermap_iterate (cp_map,
+ &clean_peer, NULL);
GNUNET_CONTAINER_multipeermap_destroy (cp_map);
cp_map = NULL;
GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);