diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-12-10 16:31:20 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-12-10 16:31:20 +0000 |
commit | 79d5251a7a1f15cba527d1f6d6d584499e678a82 (patch) | |
tree | e1ddf5268d218fb1fd3fd5451da33f2d617eee07 /src/consensus | |
parent | c283a6775a6438f7da5c3173b3993f78d1369a7d (diff) | |
download | gnunet-79d5251a7a1f15cba527d1f6d6d584499e678a82.tar.gz gnunet-79d5251a7a1f15cba527d1f6d6d584499e678a82.zip |
More statistics.
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/Makefile.am | 2 | ||||
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 30 | ||||
-rw-r--r-- | src/consensus/test_consensus.conf | 2 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am index eb0370eb5..b79e92c60 100644 --- a/src/consensus/Makefile.am +++ b/src/consensus/Makefile.am | |||
@@ -46,6 +46,7 @@ gnunet_service_consensus_LDADD = \ | |||
46 | $(top_builddir)/src/util/libgnunetutil.la \ | 46 | $(top_builddir)/src/util/libgnunetutil.la \ |
47 | $(top_builddir)/src/core/libgnunetcore.la \ | 47 | $(top_builddir)/src/core/libgnunetcore.la \ |
48 | $(top_builddir)/src/set/libgnunetset.la \ | 48 | $(top_builddir)/src/set/libgnunetset.la \ |
49 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
49 | $(GN_LIBINTL) | 50 | $(GN_LIBINTL) |
50 | 51 | ||
51 | gnunet_service_evil_consensus_SOURCES = \ | 52 | gnunet_service_evil_consensus_SOURCES = \ |
@@ -55,6 +56,7 @@ gnunet_service_evil_consensus_LDADD = \ | |||
55 | $(top_builddir)/src/util/libgnunetutil.la \ | 56 | $(top_builddir)/src/util/libgnunetutil.la \ |
56 | $(top_builddir)/src/core/libgnunetcore.la \ | 57 | $(top_builddir)/src/core/libgnunetcore.la \ |
57 | $(top_builddir)/src/set/libgnunetset.la \ | 58 | $(top_builddir)/src/set/libgnunetset.la \ |
59 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
58 | $(GN_LIBINTL) | 60 | $(GN_LIBINTL) |
59 | gnunet_service_evil_consensus_CFLAGS = -DEVIL | 61 | gnunet_service_evil_consensus_CFLAGS = -DEVIL |
60 | 62 | ||
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index b1c8466cb..fe69b60b6 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
30 | #include "gnunet_applications.h" | 30 | #include "gnunet_applications.h" |
31 | #include "gnunet_set_service.h" | 31 | #include "gnunet_set_service.h" |
32 | #include "gnunet_statistics_service.h" | ||
32 | #include "gnunet_consensus_service.h" | 33 | #include "gnunet_consensus_service.h" |
33 | #include "consensus_protocol.h" | 34 | #include "consensus_protocol.h" |
34 | #include "consensus.h" | 35 | #include "consensus.h" |
@@ -485,6 +486,11 @@ static struct GNUNET_SERVER_Handle *srv; | |||
485 | */ | 486 | */ |
486 | static struct GNUNET_PeerIdentity my_peer; | 487 | static struct GNUNET_PeerIdentity my_peer; |
487 | 488 | ||
489 | /** | ||
490 | * Statistics handle. | ||
491 | */ | ||
492 | struct GNUNET_STATISTICS_Handle *statistics; | ||
493 | |||
488 | 494 | ||
489 | static void | 495 | static void |
490 | finish_task (struct TaskEntry *task); | 496 | finish_task (struct TaskEntry *task); |
@@ -1226,6 +1232,14 @@ commit_set (struct ConsensusSession *session, | |||
1226 | struct Evilness evil; | 1232 | struct Evilness evil; |
1227 | 1233 | ||
1228 | get_evilness (session, &evil); | 1234 | get_evilness (session, &evil); |
1235 | if (EVILNESS_NONE != evil.type) | ||
1236 | { | ||
1237 | /* Useful for evaluation */ | ||
1238 | GNUNET_STATISTICS_set (statistics, | ||
1239 | "is evil", | ||
1240 | 1, | ||
1241 | GNUNET_NO); | ||
1242 | } | ||
1229 | switch (evil.type) | 1243 | switch (evil.type) |
1230 | { | 1244 | { |
1231 | case EVILNESS_CRAM_ALL: | 1245 | case EVILNESS_CRAM_ALL: |
@@ -1240,7 +1254,8 @@ commit_set (struct ConsensusSession *session, | |||
1240 | GNUNET_SET_commit (setop->op, set->h); | 1254 | GNUNET_SET_commit (setop->op, set->h); |
1241 | break; | 1255 | break; |
1242 | } | 1256 | } |
1243 | if ((EVILNESS_CRAM_LEAD == evil.type) && (PHASE_KIND_GRADECAST_LEADER != task->key.kind)) | 1257 | if ((EVILNESS_CRAM_LEAD == evil.type) && |
1258 | ((PHASE_KIND_GRADECAST_LEADER != task->key.kind) || SET_KIND_CURRENT != set->key.set_kind)) | ||
1244 | { | 1259 | { |
1245 | GNUNET_SET_commit (setop->op, set->h); | 1260 | GNUNET_SET_commit (setop->op, set->h); |
1246 | break; | 1261 | break; |
@@ -1282,6 +1297,10 @@ commit_set (struct ConsensusSession *session, | |||
1282 | debug_str_task_key (&task->key)); | 1297 | debug_str_task_key (&task->key)); |
1283 | #endif | 1298 | #endif |
1284 | } | 1299 | } |
1300 | GNUNET_STATISTICS_update (statistics, | ||
1301 | "# stuffed elements", | ||
1302 | evil.num, | ||
1303 | GNUNET_NO); | ||
1285 | GNUNET_SET_commit (setop->op, set->h); | 1304 | GNUNET_SET_commit (setop->op, set->h); |
1286 | break; | 1305 | break; |
1287 | case EVILNESS_SLACK: | 1306 | case EVILNESS_SLACK: |
@@ -1842,12 +1861,7 @@ task_start_reconcile (struct TaskEntry *task) | |||
1842 | set_result_cb, | 1861 | set_result_cb, |
1843 | task); | 1862 | task); |
1844 | 1863 | ||
1845 | if (GNUNET_OK != GNUNET_SET_commit (setop->op, input->h)) | 1864 | commit_set (session, task); |
1846 | { | ||
1847 | GNUNET_break (0); | ||
1848 | /* XXX: cleanup? */ | ||
1849 | return; | ||
1850 | } | ||
1851 | } | 1865 | } |
1852 | else if (task->key.peer2 == session->local_peer_idx) | 1866 | else if (task->key.peer2 == session->local_peer_idx) |
1853 | { | 1867 | { |
@@ -3006,6 +3020,7 @@ shutdown_task (void *cls, | |||
3006 | while (NULL != sessions_head) | 3020 | while (NULL != sessions_head) |
3007 | destroy_session (sessions_head); | 3021 | destroy_session (sessions_head); |
3008 | 3022 | ||
3023 | GNUNET_STATISTICS_destroy (statistics, GNUNET_YES); | ||
3009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); | 3024 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n"); |
3010 | } | 3025 | } |
3011 | 3026 | ||
@@ -3058,6 +3073,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
3058 | GNUNET_SCHEDULER_shutdown (); | 3073 | GNUNET_SCHEDULER_shutdown (); |
3059 | return; | 3074 | return; |
3060 | } | 3075 | } |
3076 | statistics = GNUNET_STATISTICS_create ("consensus", cfg); | ||
3061 | GNUNET_SERVER_add_handlers (server, server_handlers); | 3077 | GNUNET_SERVER_add_handlers (server, server_handlers); |
3062 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); | 3078 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); |
3063 | GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); | 3079 | GNUNET_SERVER_disconnect_notify (server, handle_client_disconnect, NULL); |
diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf index 73714e879..38b0d9929 100644 --- a/src/consensus/test_consensus.conf +++ b/src/consensus/test_consensus.conf | |||
@@ -5,7 +5,7 @@ GNUNET_TEST_HOME = /tmp/test-consensus/ | |||
5 | OPTIONS = -L INFO | 5 | OPTIONS = -L INFO |
6 | BINARY = gnunet-service-evil-consensus | 6 | BINARY = gnunet-service-evil-consensus |
7 | 7 | ||
8 | EVIL_SPEC = 0;cram-all;noreplace;5 | 8 | #EVIL_SPEC = 0;cram-all;noreplace;5 |
9 | #EVIL_SPEC = 0;cram;5/1;cram;5 | 9 | #EVIL_SPEC = 0;cram;5/1;cram;5 |
10 | #EVIL_SPEC = 0;cram;5/1;cram;3 | 10 | #EVIL_SPEC = 0;cram;5/1;cram;3 |
11 | 11 | ||