gnunet-nse-profiler.c | gnunet-nse-profiler.c | |||
---|---|---|---|---|
skipping to change at line 75 | skipping to change at line 75 | |||
/** | /** | |||
* How many messages have travelled an edge in both directions. | * How many messages have travelled an edge in both directions. | |||
*/ | */ | |||
unsigned long long total_nse_cross; | unsigned long long total_nse_cross; | |||
/** | /** | |||
* How many extra messages per edge (corrections) have been received. | * How many extra messages per edge (corrections) have been received. | |||
*/ | */ | |||
unsigned long long total_nse_extra; | unsigned long long total_nse_extra; | |||
/** | ||||
* How many messages have been discarded. | ||||
*/ | ||||
unsigned long long total_discarded; | ||||
}; | }; | |||
static struct NSEPeer *peer_head; | static struct NSEPeer *peer_head; | |||
static struct NSEPeer *peer_tail; | static struct NSEPeer *peer_tail; | |||
/** | /** | |||
* How long until we give up on connecting the peers? | * How long until we give up on connecting the peers? | |||
*/ | */ | |||
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15 00) | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15 00) | |||
skipping to change at line 199 | skipping to change at line 204 | |||
ok = 0; | ok = 0; | |||
} | } | |||
} | } | |||
static void | static void | |||
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
{ | { | |||
struct NSEPeer *pos; | struct NSEPeer *pos; | |||
#if VERBOSE | #if VERBOSE | |||
fprintf (stderr, "Ending test.\n"); | FPRINTF (stderr, "%s", "Ending test.\n"); | |||
#endif | #endif | |||
if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) | if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) | |||
{ | { | |||
GNUNET_SCHEDULER_cancel (disconnect_task); | GNUNET_SCHEDULER_cancel (disconnect_task); | |||
disconnect_task = GNUNET_SCHEDULER_NO_TASK; | disconnect_task = GNUNET_SCHEDULER_NO_TASK; | |||
} | } | |||
while (NULL != (pos = peer_head)) | while (NULL != (pos = peer_head)) | |||
{ | { | |||
if (pos->nse_handle != NULL) | if (pos->nse_handle != NULL) | |||
GNUNET_NSE_disconnect (pos->nse_handle); | GNUNET_NSE_disconnect (pos->nse_handle); | |||
GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); | |||
if (GNUNET_SCHEDULER_NO_TASK != pos->stats_task) | ||||
{ | ||||
GNUNET_SCHEDULER_cancel (pos->stats_task); | ||||
if (NULL != pos->stats) | ||||
GNUNET_STATISTICS_destroy(pos->stats, GNUNET_NO); | ||||
} | ||||
GNUNET_free (pos); | GNUNET_free (pos); | |||
} | } | |||
if (data_file != NULL) | if (data_file != NULL) | |||
GNUNET_DISK_file_close (data_file); | GNUNET_DISK_file_close (data_file); | |||
GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | |||
} | } | |||
/** | /** | |||
* Callback to call when network size estimate is updated. | * Callback to call when network size estimate is updated. | |||
skipping to change at line 251 | skipping to change at line 262 | |||
GNUNET_asprintf (&output_buffer, "%s %llu %llu %f %f %f\n", | GNUNET_asprintf (&output_buffer, "%s %llu %llu %f %f %f\n", | |||
GNUNET_i2s (&peer->daemon->id), peers_running, | GNUNET_i2s (&peer->daemon->id), peers_running, | |||
timestamp.abs_value, | timestamp.abs_value, | |||
GNUNET_NSE_log_estimate_to_n (estimate), estimate, | GNUNET_NSE_log_estimate_to_n (estimate), estimate, | |||
std_dev); | std_dev); | |||
if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) | if (size != GNUNET_DISK_file_write (output_file, output_buffer, size)) | |||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | |||
GNUNET_free (output_buffer); | GNUNET_free (output_buffer); | |||
} | } | |||
else | else | |||
fprintf (stderr, | FPRINTF (stderr, | |||
"Received network size estimate from peer %s. Size: %f std.dev . %f\n", | "Received network size estimate from peer %s. Size: %f std.dev . %f\n", | |||
GNUNET_i2s (&peer->daemon->id), estimate, std_dev); | GNUNET_i2s (&peer->daemon->id), estimate, std_dev); | |||
} | } | |||
/** | /** | |||
* Process core statistic values. | * Process core statistic values. | |||
* | * | |||
* @param cls closure | * @param cls closure | |||
* @param subsystem name of subsystem that created the statistic | * @param subsystem name of subsystem that created the statistic | |||
skipping to change at line 308 | skipping to change at line 319 | |||
* successfully obtained, GNUNET_SYSERR if not. | * successfully obtained, GNUNET_SYSERR if not. | |||
*/ | */ | |||
static void | static void | |||
core_stats_cont (void *cls, int success); | core_stats_cont (void *cls, int success); | |||
static void | static void | |||
core_get_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | core_get_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
{ | { | |||
struct NSEPeer *peer = cls; | struct NSEPeer *peer = cls; | |||
peer->stats_task = GNUNET_SCHEDULER_NO_TASK; | ||||
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | |||
{ | { | |||
GNUNET_STATISTICS_destroy(peer->stats, GNUNET_NO); | GNUNET_STATISTICS_destroy(peer->stats, GNUNET_NO); | |||
peer->stats = NULL; | peer->stats = NULL; | |||
return; | ||||
} | } | |||
else | else | |||
{ | { | |||
GNUNET_STATISTICS_get(peer->stats, "core", NULL, | GNUNET_STATISTICS_get(peer->stats, "core", NULL, | |||
GNUNET_TIME_UNIT_FOREVER_REL, | GNUNET_TIME_UNIT_FOREVER_REL, | |||
&core_stats_cont, &core_stats_iterator, peer); | &core_stats_cont, &core_stats_iterator, peer); | |||
GNUNET_STATISTICS_get(peer->stats, "transport", NULL, | GNUNET_STATISTICS_get(peer->stats, "transport", NULL, | |||
GNUNET_TIME_UNIT_FOREVER_REL, | GNUNET_TIME_UNIT_FOREVER_REL, | |||
NULL, &core_stats_iterator, peer); | NULL, &core_stats_iterator, peer); | |||
GNUNET_STATISTICS_get(peer->stats, "nse", NULL, | GNUNET_STATISTICS_get(peer->stats, "nse", NULL, | |||
GNUNET_TIME_UNIT_FOREVER_REL, | GNUNET_TIME_UNIT_FOREVER_REL, | |||
NULL, &core_stats_iterator, peer); | NULL, &core_stats_iterator, peer); | |||
} | } | |||
peer->stats_task = GNUNET_SCHEDULER_NO_TASK; | ||||
} | } | |||
/** | /** | |||
* Continuation called by "get_stats" function. | * Continuation called by "get_stats" function. | |||
* | * | |||
* @param cls closure | * @param cls closure | |||
* @param success GNUNET_OK if statistics were | * @param success GNUNET_OK if statistics were | |||
* successfully obtained, GNUNET_SYSERR if not. | * successfully obtained, GNUNET_SYSERR if not. | |||
*/ | */ | |||
static void | static void | |||
skipping to change at line 451 | skipping to change at line 463 | |||
buf_len = | buf_len = | |||
GNUNET_asprintf (&buf, "TOTAL_NSE_EXTRA_%d: %u \n", | GNUNET_asprintf (&buf, "TOTAL_NSE_EXTRA_%d: %u \n", | |||
stats_context->shutdown, | stats_context->shutdown, | |||
stats_context->total_nse_extra); | stats_context->total_nse_extra); | |||
if (buf_len > 0) | if (buf_len > 0) | |||
{ | { | |||
GNUNET_DISK_file_write (data_file, buf, buf_len); | GNUNET_DISK_file_write (data_file, buf, buf_len); | |||
} | } | |||
GNUNET_free_non_null (buf); | GNUNET_free_non_null (buf); | |||
buf = NULL; | ||||
buf_len = | ||||
GNUNET_asprintf (&buf, "TOTAL_NSE_DISCARDED_%d: %u \n", | ||||
stats_context->shutdown, | ||||
stats_context->total_discarded); | ||||
if (buf_len > 0) | ||||
{ | ||||
GNUNET_DISK_file_write (data_file, buf, buf_len); | ||||
} | ||||
GNUNET_free_non_null (buf); | ||||
} | } | |||
if (GNUNET_YES == stats_context->shutdown) | if (GNUNET_YES == stats_context->shutdown) | |||
{ | { | |||
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == shutdown_handle); | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == shutdown_handle); | |||
shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | |||
} | } | |||
else | else | |||
{ | { | |||
GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); | GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); | |||
skipping to change at line 535 | skipping to change at line 558 | |||
#endif | #endif | |||
} | } | |||
if (0 == strcmp (name, "# cross messages")) | if (0 == strcmp (name, "# cross messages")) | |||
{ | { | |||
stats_context->total_nse_cross += value; | stats_context->total_nse_cross += value; | |||
} | } | |||
if (0 == strcmp (name, "# extra messages")) | if (0 == strcmp (name, "# extra messages")) | |||
{ | { | |||
stats_context->total_nse_extra += value; | stats_context->total_nse_extra += value; | |||
} | } | |||
if (0 == strcmp (name, "# flood messages discarded (clock skew too larg | ||||
e)")) | ||||
{ | ||||
stats_context->total_discarded += value; | ||||
} | ||||
} | } | |||
return GNUNET_OK; | return GNUNET_OK; | |||
} | } | |||
static void | static void | |||
disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | disconnect_nse_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
{ | { | |||
struct NSEPeer *pos; | struct NSEPeer *pos; | |||
char *buf; | char *buf; | |||
struct StatsContext *stats_context; | struct StatsContext *stats_context; | |||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnecting nse service of peers\ n"); | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnecting nse service of peers\ n"); | |||
disconnect_task = GNUNET_SCHEDULER_NO_TASK; | disconnect_task = GNUNET_SCHEDULER_NO_TASK; | |||
pos = peer_head; | ||||
while (NULL != (pos = peer_head)) | while (NULL != (pos = peer_head)) | |||
{ | { | |||
if (pos->nse_handle != NULL) | if (pos->nse_handle != NULL) | |||
{ | { | |||
GNUNET_NSE_disconnect (pos->nse_handle); | GNUNET_NSE_disconnect (pos->nse_handle); | |||
pos->nse_handle = NULL; | pos->nse_handle = NULL; | |||
} | } | |||
GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); | |||
if (NULL != pos->stats) | if (NULL != pos->stats) | |||
GNUNET_STATISTICS_destroy(pos->stats, GNUNET_NO); | GNUNET_STATISTICS_destroy(pos->stats, GNUNET_NO); | |||
End of changes. 10 change blocks. | ||||
4 lines changed or deleted | 31 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |