ret = GNUNET_CONTAINER_multipeermap_put (sub->peer_map, peer, ctx,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
GNUNET_assert (GNUNET_OK == ret);
- GNUNET_STATISTICS_set (stats,
- "# known peers",
- GNUNET_CONTAINER_multipeermap_size (sub->peer_map),
- GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "# known peers",
+ GNUNET_CONTAINER_multipeermap_size (sub->peer_map),
+ GNUNET_NO);
+ }
return ctx;
}
}
(void) GNUNET_CONTAINER_multipeermap_put (valid_peers, peer, NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
- GNUNET_STATISTICS_set (stats,
- "# valid peers",
- GNUNET_CONTAINER_multipeermap_size (valid_peers),
- GNUNET_NO);
+ if (valid_peers == msub->valid_peers)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "# valid peers",
+ GNUNET_CONTAINER_multipeermap_size (valid_peers),
+ GNUNET_NO);
+ }
return ret;
}
mq_online_check_successful,
peer_ctx);
GNUNET_MQ_send (mq, ev);
- GNUNET_STATISTICS_update (stats,
- "# pending online checks",
- 1,
- GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# pending online checks",
+ 1,
+ GNUNET_NO);
+ }
}
sizeof (struct PendingMessage))) )
{
peer_ctx->online_check_pending = NULL;
- GNUNET_STATISTICS_update (stats,
- "# pending online checks",
- -1,
- GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# pending online checks",
+ -1,
+ GNUNET_NO);
+ }
}
remove_pending_message (peer_ctx->pending_messages_head,
GNUNET_YES);
LOG (GNUNET_ERROR_TYPE_WARNING,
"removing peer from peer_ctx->sub->peer_map failed\n");
}
- GNUNET_STATISTICS_set (stats,
- "# known peers",
- GNUNET_CONTAINER_multipeermap_size (peer_ctx->sub->peer_map),
- GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "# known peers",
+ GNUNET_CONTAINER_multipeermap_size (peer_ctx->sub->peer_map),
+ GNUNET_NO);
+ }
GNUNET_free (peer_ctx);
return GNUNET_YES;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"%s was sent.\n",
pending_msg->type);
- if (0 == strncmp ("PULL REPLY", pending_msg->type, 10))
- GNUNET_STATISTICS_update(stats, "# pull replys sent", 1, GNUNET_NO);
- if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12))
- GNUNET_STATISTICS_update(stats, "# pull requests sent", 1, GNUNET_NO);
- if (0 == strncmp ("PUSH", pending_msg->type, 4))
- GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO);
+ if (pending_msg->peer_ctx->sub == msub)
+ {
+ if (0 == strncmp ("PULL REPLY", pending_msg->type, 10))
+ GNUNET_STATISTICS_update(stats, "# pull replys sent", 1, GNUNET_NO);
+ if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12))
+ GNUNET_STATISTICS_update(stats, "# pull requests sent", 1, GNUNET_NO);
+ if (0 == strncmp ("PUSH", pending_msg->type, 4))
+ GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO);
+ }
/* Do not cancle message */
remove_pending_message (pending_msg, GNUNET_NO);
}
/* Open channel towards peer to keep connection open */
indicate_sending_intention (peer_ctx);
ret = View_put (sub->view, peer);
- GNUNET_STATISTICS_set (stats,
- "view size",
- View_size (peer_ctx->sub->view),
- GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "view size",
+ View_size (peer_ctx->sub->view),
+ GNUNET_NO);
+ }
return ret;
}
{
struct GNUNET_MQ_Envelope *ev;
struct GNUNET_RPS_CS_DEBUG_ViewReply *out_msg;
+ struct Sub *sub;
if (NULL == view_array)
{
- if (NULL == cli_ctx->sub)
- {
- view_size = View_size (msub->view);
- view_array = View_get_as_array (msub->view);
- }
- else
- {
- view_size = View_size (cli_ctx->sub->view);
- view_array = View_get_as_array (cli_ctx->sub->view);
- }
+ if (NULL == cli_ctx->sub) sub = msub;
+ else sub = cli_ctx->sub;
+ view_size = View_size (sub->view);
+ view_array = View_get_as_array (sub->view);
}
ev = GNUNET_MQ_msg_extra (out_msg,
&peer_array[i],
NULL,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- GNUNET_STATISTICS_set (stats,
- "# known peers",
- GNUNET_CONTAINER_multipeermap_size (peer_map),
- GNUNET_NO);
+ if (msub->peer_map == peer_map)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "# known peers",
+ GNUNET_CONTAINER_multipeermap_size (peer_map),
+ GNUNET_NO);
+ }
}
}
send_size * sizeof (struct GNUNET_PeerIdentity));
send_message (peer_ctx, ev, "PULL REPLY");
- GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO);
+ }
// TODO check with send intention: as send_channel is used/opened we indicate
// a sending intention without intending it.
// -> clean peer afterwards?
schedule_operation (get_peer_ctx (sub->peer_map, peer),
&insert_in_view_op, sub);
}
- GNUNET_STATISTICS_update (stats,
- "# learnd peers",
- 1,
- GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# learnd peers",
+ 1,
+ GNUNET_NO);
+ }
}
sub->pull_map = CustomPeerMap_create (4);
sub->view_size_est_min = sampler_size;;
sub->view = View_create (sub->view_size_est_min);
- GNUNET_STATISTICS_set (stats,
- "view size aim",
- sub->view_size_est_min,
- GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "view size aim",
+ sub->view_size_est_min,
+ GNUNET_NO);
+ }
/* Start executing rounds */
sub->do_round_task = GNUNET_SCHEDULER_add_now (&do_round, sub);
//sub->sampler_size_est_need = sub->view_size_est_min;
sub->view_size_est_need = sub->view_size_est_min;
}
- GNUNET_STATISTICS_set (stats, "view size aim", sub->view_size_est_need, GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "view size aim",
+ sub->view_size_est_need,
+ GNUNET_NO);
+ }
/* If the NSE has changed adapt the lists accordingly */
resize_wrapper (sub->sampler, sub->sampler_size_est_need);
i,
GNUNET_i2s (&peers[i]));
- if (NULL != msub) got_peer (msub, &peers[i]);
+ if (NULL != msub) got_peer (msub, &peers[i]); /* Condition needed? */
if (NULL != cli_ctx->sub) got_peer (cli_ctx->sub, &peers[i]);
}
GNUNET_SERVICE_client_continue (cli_ctx->client);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer));
- GNUNET_STATISTICS_update (stats,
- "# pending online checks",
- -1,
- GNUNET_NO);
+ if (channel_ctx->peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# pending online checks",
+ -1,
+ GNUNET_NO);
+ }
GNUNET_CADET_receive_done (channel_ctx->channel);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received PUSH (%s)\n",
GNUNET_i2s (peer));
- GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO);
+ if (channel_ctx->peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO);
+ }
#ifdef ENABLE_MALICIOUS
struct AttackedPeer *tmp_att_peer;
(void) msg;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer));
- GNUNET_STATISTICS_update(stats, "# pull request message received", 1, GNUNET_NO);
+ if (peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update(stats,
+ "# pull request message received",
+ 1,
+ GNUNET_NO);
+ }
#ifdef ENABLE_MALICIOUS
if (1 == mal_type
LOG (GNUNET_ERROR_TYPE_WARNING,
"Received a pull reply from a peer (%s) we didn't request one from!\n",
GNUNET_i2s (&sender_ctx->peer_id));
- GNUNET_STATISTICS_update (stats,
- "# unrequested pull replies",
- 1,
- GNUNET_NO);
+ if (sender_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# unrequested pull replies",
+ 1,
+ GNUNET_NO);
+ }
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
#endif /* ENABLE_MALICIOUS */
LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s (sender));
- GNUNET_STATISTICS_update(stats, "# pull reply messages received", 1, GNUNET_NO);
+ if (channel_ctx->peer_ctx->sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# pull reply messages received",
+ 1,
+ GNUNET_NO);
+ }
#ifdef ENABLE_MALICIOUS
// We shouldn't even receive pull replies as we're not sending
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST);
send_message (peer_ctx, ev, "PULL REQUEST");
- GNUNET_STATISTICS_update(stats, "# pull request send issued", 1, GNUNET_NO);
+ if (peer_ctx->sub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# pull request send issued",
+ 1,
+ GNUNET_NO);
+ }
}
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH);
send_message (peer_ctx, ev, "PUSH");
- GNUNET_STATISTICS_update(stats, "# push send issued", 1, GNUNET_NO);
+ if (peer_ctx->sub)
+ {
+ GNUNET_STATISTICS_update (stats,
+ "# push send issued",
+ 1,
+ GNUNET_NO);
+ }
}
uint32_t num_mal_peers_old;
struct Sub *sub = cli_ctx->sub;
+ if (NULL == sub) sub = msub;
/* Do actual logic */
peers = (struct GNUNET_PeerIdentity *) &msg[1];
mal_type = ntohl (msg->type);
mal_peer_set);
/* Substitute do_round () with do_mal_round () */
- if (NULL != sub)
- {
- GNUNET_SCHEDULER_cancel (sub->do_round_task);
- sub->do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, sub);
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "do_round_task is NULL, probably in shutdown\n");
- }
+ GNUNET_assert (NULL != sub->do_round_task);
+ GNUNET_SCHEDULER_cancel (sub->do_round_task);
+ sub->do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, sub);
}
else if ( (2 == mal_type) ||
&msg->attacked_peer,
sizeof (struct GNUNET_PeerIdentity));
/* Set the flag of the attacked peer to valid to avoid problems */
- if (NULL != sub &&
- GNUNET_NO == check_peer_known (sub->peer_map, &attacked_peer))
+ if (GNUNET_NO == check_peer_known (sub->peer_map, &attacked_peer))
{
(void) issue_peer_online_check (sub, &attacked_peer);
}
GNUNET_i2s (&attacked_peer));
/* Substitute do_round () with do_mal_round () */
- if (NULL != sub && NULL != sub->do_round_task)
+ if (NULL != sub->do_round_task)
{
/* Probably in shutdown */
GNUNET_SCHEDULER_cancel (sub->do_round_task);
}
#endif /* ENABLE_MALICIOUS */
+
/**
* Send out PUSHes and PULLs, possibly update #view, samplers.
*
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Going to execute next round.\n");
- GNUNET_STATISTICS_update(stats, "# rounds", 1, GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_update (stats, "# rounds", 1, GNUNET_NO);
+ }
sub->do_round_task = NULL;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Printing view:\n");
clients_notify_view_update (sub);
} else {
LOG (GNUNET_ERROR_TYPE_DEBUG, "No update of the view.\n");
- GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO);
- if (CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
- !(0 >= CustomPeerMap_size (sub->pull_map)))
- GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, GNUNET_NO);
- if (CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
- (0 >= CustomPeerMap_size (sub->pull_map)))
- GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes, no pull replies", 1, GNUNET_NO);
- if (0 >= CustomPeerMap_size (sub->push_map) &&
- !(0 >= CustomPeerMap_size (sub->pull_map)))
- GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, GNUNET_NO);
- if (0 >= CustomPeerMap_size (sub->push_map) &&
- (0 >= CustomPeerMap_size (sub->pull_map)))
- GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes, no pull replies", 1, GNUNET_NO);
- if (0 >= CustomPeerMap_size (sub->pull_map) &&
- CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
- 0 >= CustomPeerMap_size (sub->push_map))
- GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_update(stats, "# rounds blocked", 1, GNUNET_NO);
+ if (CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
+ !(0 >= CustomPeerMap_size (sub->pull_map)))
+ GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes", 1, GNUNET_NO);
+ if (CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
+ (0 >= CustomPeerMap_size (sub->pull_map)))
+ GNUNET_STATISTICS_update(stats, "# rounds blocked - too many pushes, no pull replies", 1, GNUNET_NO);
+ if (0 >= CustomPeerMap_size (sub->push_map) &&
+ !(0 >= CustomPeerMap_size (sub->pull_map)))
+ GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes", 1, GNUNET_NO);
+ if (0 >= CustomPeerMap_size (sub->push_map) &&
+ (0 >= CustomPeerMap_size (sub->pull_map)))
+ GNUNET_STATISTICS_update(stats, "# rounds blocked - no pushes, no pull replies", 1, GNUNET_NO);
+ if (0 >= CustomPeerMap_size (sub->pull_map) &&
+ CustomPeerMap_size (sub->push_map) > alpha * View_size (sub->view) &&
+ 0 >= CustomPeerMap_size (sub->push_map))
+ GNUNET_STATISTICS_update(stats, "# rounds blocked - no pull replies", 1, GNUNET_NO);
+ }
}
// TODO independent of that also get some peers from CADET_get_peers()?
- GNUNET_STATISTICS_set (stats,
- "# peers in push map at end of round",
- CustomPeerMap_size (sub->push_map),
- GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "# peers in pull map at end of round",
- CustomPeerMap_size (sub->pull_map),
- GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "# peers in view at end of round",
- View_size (sub->view),
- GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "# peers in push map at end of round",
+ CustomPeerMap_size (sub->push_map),
+ GNUNET_NO);
+ GNUNET_STATISTICS_set (stats,
+ "# peers in pull map at end of round",
+ CustomPeerMap_size (sub->pull_map),
+ GNUNET_NO);
+ GNUNET_STATISTICS_set (stats,
+ "# peers in view at end of round",
+ View_size (sub->view),
+ GNUNET_NO);
+ }
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received %u pushes and %u pulls last round (alpha (%.2f) * view_size (sub->view%u) = %.2f)\n",
CustomPeerMap_clear (sub->push_map);
CustomPeerMap_clear (sub->pull_map);
- GNUNET_STATISTICS_set (stats,
- "view size",
- View_size(sub->view),
- GNUNET_NO);
+ if (sub == msub)
+ {
+ GNUNET_STATISTICS_set (stats,
+ "view size",
+ View_size(sub->view),
+ GNUNET_NO);
+ }
struct GNUNET_TIME_Relative time_next_round;