diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-04-11 01:49:49 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-04-11 01:49:49 +0000 |
commit | f78f7a837db6f5203a28432c12f206cf59436e2b (patch) | |
tree | 5b6af36d6a7d226867666c093859f081ab721a79 /src/nse | |
parent | 804486fd4779aee6b3b92ad11c0261c663b27fe4 (diff) | |
download | gnunet-f78f7a837db6f5203a28432c12f206cf59436e2b.tar.gz gnunet-f78f7a837db6f5203a28432c12f206cf59436e2b.zip |
- Added more debug info, cleaned code, tried to fix boot time part of #2202
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 4fbef3105..306d047bc 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -59,7 +59,7 @@ | |||
59 | * production). The associated code should also probably be removed | 59 | * production). The associated code should also probably be removed |
60 | * once we're done with experiments. | 60 | * once we're done with experiments. |
61 | */ | 61 | */ |
62 | #define ENABLE_HISTOGRAM GNUNET_NO | 62 | #define ENABLE_HISTOGRAM GNUNET_YES |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Over how many values do we calculate the weighted average? | 65 | * Over how many values do we calculate the weighted average? |
@@ -130,7 +130,9 @@ struct NSEPeerEntry | |||
130 | * Where a variable has been modified to cause a bug. | 130 | * Where a variable has been modified to cause a bug. |
131 | * FIXME DELETE AFTER DEBUG | 131 | * FIXME DELETE AFTER DEBUG |
132 | */ | 132 | */ |
133 | const char *where; | 133 | int where_task; |
134 | int where_round; | ||
135 | int where_th; | ||
134 | 136 | ||
135 | #if ENABLE_HISTOGRAM | 137 | #if ENABLE_HISTOGRAM |
136 | 138 | ||
@@ -575,14 +577,15 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
575 | unsigned int idx; | 577 | unsigned int idx; |
576 | 578 | ||
577 | peer_entry->th = NULL; | 579 | peer_entry->th = NULL; |
578 | if (buf == NULL) | 580 | peer_entry->where_th = __LINE__; |
581 | if (NULL == buf) | ||
579 | { | 582 | { |
580 | /* client disconnected */ | 583 | /* client disconnected */ |
581 | return 0; | 584 | return 0; |
582 | } | 585 | } |
583 | GNUNET_assert (size >= sizeof (struct GNUNET_NSE_FloodMessage)); | 586 | GNUNET_assert (size >= sizeof (struct GNUNET_NSE_FloodMessage)); |
584 | idx = estimate_index; | 587 | idx = estimate_index; |
585 | if (peer_entry->previous_round == GNUNET_NO) | 588 | if (GNUNET_NO == peer_entry->previous_round) |
586 | { | 589 | { |
587 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; | 590 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; |
588 | peer_entry->previous_round = GNUNET_YES; | 591 | peer_entry->previous_round = GNUNET_YES; |
@@ -641,6 +644,8 @@ transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
641 | struct NSEPeerEntry *peer_entry = cls; | 644 | struct NSEPeerEntry *peer_entry = cls; |
642 | 645 | ||
643 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 646 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
647 | peer_entry->where_task = __LINE__; | ||
648 | |||
644 | GNUNET_assert (NULL == peer_entry->th); | 649 | GNUNET_assert (NULL == peer_entry->th); |
645 | peer_entry->th = | 650 | peer_entry->th = |
646 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO, NSE_PRIORITY, | 651 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_NO, NSE_PRIORITY, |
@@ -649,6 +654,7 @@ transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
649 | sizeof (struct | 654 | sizeof (struct |
650 | GNUNET_NSE_FloodMessage), | 655 | GNUNET_NSE_FloodMessage), |
651 | &transmit_ready, peer_entry); | 656 | &transmit_ready, peer_entry); |
657 | peer_entry->where_th = __LINE__; | ||
652 | } | 658 | } |
653 | 659 | ||
654 | 660 | ||
@@ -722,14 +728,14 @@ schedule_current_round (void *cls, const GNUNET_HashCode * key, void *value) | |||
722 | if (NULL != peer_entry->th) | 728 | if (NULL != peer_entry->th) |
723 | { | 729 | { |
724 | peer_entry->previous_round = GNUNET_NO; | 730 | peer_entry->previous_round = GNUNET_NO; |
725 | peer_entry->where = __FUNCTION__; | 731 | peer_entry->where_round = __LINE__; |
726 | return GNUNET_OK; | 732 | return GNUNET_OK; |
727 | } | 733 | } |
728 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) | 734 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) |
729 | { | 735 | { |
730 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 736 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
731 | peer_entry->previous_round = GNUNET_NO; | 737 | peer_entry->previous_round = GNUNET_NO; |
732 | peer_entry->where = __FUNCTION__; | 738 | peer_entry->where_round = __LINE__; |
733 | } | 739 | } |
734 | #if ENABLE_HISTOGRAM | 740 | #if ENABLE_HISTOGRAM |
735 | if (peer_entry->received_messages > 1) | 741 | if (peer_entry->received_messages > 1) |
@@ -987,14 +993,22 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) | |||
987 | { | 993 | { |
988 | /* still stuck in previous round, no point to update, check that | 994 | /* still stuck in previous round, no point to update, check that |
989 | * we are active here though... */ | 995 | * we are active here though... */ |
990 | GNUNET_break (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task || | 996 | if (GNUNET_SCHEDULER_NO_TASK == peer_entry->transmit_task && |
991 | NULL != peer_entry->th); | 997 | NULL == peer_entry->th) |
998 | { | ||
999 | GNUNET_break (0); | ||
1000 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ROUND%d TASK%d TH%d\n", | ||
1001 | peer_entry->where_round, | ||
1002 | peer_entry->where_task, | ||
1003 | peer_entry->where_th); | ||
1004 | } | ||
992 | return GNUNET_OK; | 1005 | return GNUNET_OK; |
993 | } | 1006 | } |
994 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 1007 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
995 | { | 1008 | { |
996 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1009 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
997 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 1010 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
1011 | peer_entry->where_task = __LINE__; | ||
998 | } | 1012 | } |
999 | delay = get_transmit_delay (0); | 1013 | delay = get_transmit_delay (0); |
1000 | peer_entry->transmit_task = | 1014 | peer_entry->transmit_task = |
@@ -1116,11 +1130,13 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1116 | { | 1130 | { |
1117 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1131 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
1118 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 1132 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
1133 | peer_entry->where_task = __LINE__; | ||
1119 | } | 1134 | } |
1120 | if (peer_entry->th != NULL) | 1135 | if (peer_entry->th != NULL) |
1121 | { | 1136 | { |
1122 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); | 1137 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); |
1123 | peer_entry->th = NULL; | 1138 | peer_entry->th = NULL; |
1139 | peer_entry->where_th = __LINE__; | ||
1124 | } | 1140 | } |
1125 | return GNUNET_OK; | 1141 | return GNUNET_OK; |
1126 | } | 1142 | } |
@@ -1128,7 +1144,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1128 | { | 1144 | { |
1129 | if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) { | 1145 | if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) { |
1130 | peer_entry->previous_round = GNUNET_NO; | 1146 | peer_entry->previous_round = GNUNET_NO; |
1131 | peer_entry->where = __FUNCTION__ ; | 1147 | peer_entry->where_round = __LINE__; |
1132 | } | 1148 | } |
1133 | /* push back our result now, that peer is spreading bad information... */ | 1149 | /* push back our result now, that peer is spreading bad information... */ |
1134 | if (NULL == peer_entry->th) | 1150 | if (NULL == peer_entry->th) |
@@ -1155,15 +1171,18 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1155 | if (idx == estimate_index) | 1171 | if (idx == estimate_index) |
1156 | { | 1172 | { |
1157 | /* cancel any activity for current round */ | 1173 | /* cancel any activity for current round */ |
1174 | // FIXME what if previous round was pending? (lost message?) | ||
1158 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 1175 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
1159 | { | 1176 | { |
1160 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1177 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
1161 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 1178 | peer_entry->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
1179 | peer_entry->where_task = __LINE__; | ||
1162 | } | 1180 | } |
1163 | if (peer_entry->th != NULL) | 1181 | if (peer_entry->th != NULL) |
1164 | { | 1182 | { |
1165 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); | 1183 | GNUNET_CORE_notify_transmit_ready_cancel (peer_entry->th); |
1166 | peer_entry->th = NULL; | 1184 | peer_entry->th = NULL; |
1185 | peer_entry->where_th = __LINE__; | ||
1167 | } | 1186 | } |
1168 | } | 1187 | } |
1169 | else | 1188 | else |
@@ -1220,8 +1239,10 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1220 | peer_entry->transmit_task = | 1239 | peer_entry->transmit_task = |
1221 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, | 1240 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, |
1222 | peer_entry); | 1241 | peer_entry); |
1223 | peer_entry->where = "core connect"; | ||
1224 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); | 1242 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); |
1243 | peer_entry->where_task = 0; | ||
1244 | peer_entry->where_round = __LINE__; | ||
1245 | peer_entry->where_th = __LINE__; | ||
1225 | } | 1246 | } |
1226 | 1247 | ||
1227 | 1248 | ||
@@ -1253,11 +1274,13 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1253 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) { | 1274 | if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) { |
1254 | GNUNET_SCHEDULER_cancel (pos->transmit_task); | 1275 | GNUNET_SCHEDULER_cancel (pos->transmit_task); |
1255 | pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; | 1276 | pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; |
1277 | pos->where_task = __LINE__; | ||
1256 | } | 1278 | } |
1257 | if (pos->th != NULL) | 1279 | if (pos->th != NULL) |
1258 | { | 1280 | { |
1259 | GNUNET_CORE_notify_transmit_ready_cancel (pos->th); | 1281 | GNUNET_CORE_notify_transmit_ready_cancel (pos->th); |
1260 | pos->th = NULL; | 1282 | pos->th = NULL; |
1283 | pos->where_th = __LINE__; | ||
1261 | } | 1284 | } |
1262 | GNUNET_free (pos); | 1285 | GNUNET_free (pos); |
1263 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); | 1286 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); |
@@ -1333,7 +1356,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1333 | struct GNUNET_TIME_Absolute now; | 1356 | struct GNUNET_TIME_Absolute now; |
1334 | struct GNUNET_TIME_Absolute prev_time; | 1357 | struct GNUNET_TIME_Absolute prev_time; |
1335 | 1358 | ||
1336 | if (server == NULL) | 1359 | if (NULL == server) |
1337 | { | 1360 | { |
1338 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n"); | 1361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connection to core FAILED!\n"); |
1339 | GNUNET_SCHEDULER_shutdown (); | 1362 | GNUNET_SCHEDULER_shutdown (); |
@@ -1352,9 +1375,10 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1352 | estimate_count = 0; | 1375 | estimate_count = 0; |
1353 | if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof)) | 1376 | if (GNUNET_YES == check_proof_of_work (&my_public_key, my_proof)) |
1354 | { | 1377 | { |
1378 | int idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE; | ||
1355 | prev_time.abs_value = | 1379 | prev_time.abs_value = |
1356 | current_timestamp.abs_value - gnunet_nse_interval.rel_value; | 1380 | current_timestamp.abs_value - gnunet_nse_interval.rel_value; |
1357 | setup_flood_message (estimate_index, prev_time); | 1381 | setup_flood_message (idx, prev_time); |
1358 | estimate_count++; | 1382 | estimate_count++; |
1359 | } | 1383 | } |
1360 | flood_task = | 1384 | flood_task = |