diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-12-08 17:51:51 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-12-08 17:51:51 +0000 |
commit | 2534ceaa636e3b0254d9187885027896b9d3e840 (patch) | |
tree | c41607872fc7b104ff7dbce161e67cccd050f7b2 /src/nse | |
parent | 33867ff5ec4161633b5f0efeca2f9daad9a8ef78 (diff) | |
download | gnunet-2534ceaa636e3b0254d9187885027896b9d3e840.tar.gz gnunet-2534ceaa636e3b0254d9187885027896b9d3e840.zip |
- Fixed message accounting, file creation flags, added logging in verbose mode
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 078628faa..d3ff044c2 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -49,7 +49,7 @@ struct NSEPeer | |||
49 | 49 | ||
50 | struct StatsContext | 50 | struct StatsContext |
51 | { | 51 | { |
52 | unsigned long long total_nse_bytes; | 52 | unsigned long long total_nse_messages; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
@@ -390,8 +390,8 @@ stats_finished_callback (void *cls, int success) | |||
390 | /* Stats lookup successful, write out data */ | 390 | /* Stats lookup successful, write out data */ |
391 | buf = NULL; | 391 | buf = NULL; |
392 | buf_len = | 392 | buf_len = |
393 | GNUNET_asprintf (&buf, "TOTAL_NSE_BYTES: %u\n", | 393 | GNUNET_asprintf (&buf, "TOTAL_NSE_MESSAGES: %u\n", |
394 | stats_context->total_nse_bytes); | 394 | stats_context->total_nse_messages); |
395 | if (buf_len > 0) | 395 | if (buf_len > 0) |
396 | { | 396 | { |
397 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 397 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
@@ -423,9 +423,27 @@ statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
423 | { | 423 | { |
424 | struct StatsContext *stats_context = cls; | 424 | struct StatsContext *stats_context = cls; |
425 | 425 | ||
426 | if ((0 == strstr (subsystem, "nse")) && | 426 | if ((0 == strcmp (subsystem, "nse")) && |
427 | (0 == strstr (name, "# flood messages received"))) | 427 | (0 == strcmp (name, "# flood messages received"))) |
428 | stats_context->total_nse_bytes += value; | 428 | { |
429 | stats_context->total_nse_messages += value; | ||
430 | #if VERBOSE | ||
431 | if (data_file != NULL) | ||
432 | { | ||
433 | char *buf; | ||
434 | int buf_len; | ||
435 | |||
436 | buf = NULL; | ||
437 | buf_len = | ||
438 | GNUNET_asprintf (&buf, "Peer %s: %u\n", GNUNET_i2s(peer), value); | ||
439 | if (buf_len > 0) | ||
440 | { | ||
441 | GNUNET_DISK_file_write (data_file, buf, buf_len); | ||
442 | } | ||
443 | GNUNET_free_non_null (buf); | ||
444 | } | ||
445 | #endif | ||
446 | } | ||
429 | return GNUNET_OK; | 447 | return GNUNET_OK; |
430 | } | 448 | } |
431 | 449 | ||
@@ -710,6 +728,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
710 | data_file = | 728 | data_file = |
711 | GNUNET_DISK_file_open (data_filename, | 729 | GNUNET_DISK_file_open (data_filename, |
712 | GNUNET_DISK_OPEN_READWRITE | | 730 | GNUNET_DISK_OPEN_READWRITE | |
731 | GNUNET_DISK_OPEN_TRUNCATE | | ||
713 | GNUNET_DISK_OPEN_CREATE, | 732 | GNUNET_DISK_OPEN_CREATE, |
714 | GNUNET_DISK_PERM_USER_READ | | 733 | GNUNET_DISK_PERM_USER_READ | |
715 | GNUNET_DISK_PERM_USER_WRITE); | 734 | GNUNET_DISK_PERM_USER_WRITE); |