aboutsummaryrefslogtreecommitdiff
path: root/src/nse
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-04-10 13:25:23 +0000
committerBart Polot <bart@net.in.tum.de>2012-04-10 13:25:23 +0000
commitac232b8944eed8302bf6681ad2cb21c552545f85 (patch)
treeb0bccb069411b71f983a9fba1073ad2475228c98 /src/nse
parent3bb84941ded9aa79112ade7e97945df60006c1f4 (diff)
downloadgnunet-ac232b8944eed8302bf6681ad2cb21c552545f85.tar.gz
gnunet-ac232b8944eed8302bf6681ad2cb21c552545f85.zip
- Improved doxygen, added debug code
Diffstat (limited to 'src/nse')
-rw-r--r--src/nse/gnunet-service-nse.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index 0a9c48f58..4fbef3105 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -126,6 +126,12 @@ struct NSEPeerEntry
126 */ 126 */
127 int previous_round; 127 int previous_round;
128 128
129 /**
130 * Where a variable has been modified to cause a bug.
131 * FIXME DELETE AFTER DEBUG
132 */
133 const char *where;
134
129#if ENABLE_HISTOGRAM 135#if ENABLE_HISTOGRAM
130 136
131 /** 137 /**
@@ -597,7 +603,7 @@ transmit_ready (void *cls, size_t size, void *buf)
597 GNUNET_STATISTICS_update (stats, 603 GNUNET_STATISTICS_update (stats,
598 "# flood messages not generated (lack of history)", 604 "# flood messages not generated (lack of history)",
599 1, GNUNET_NO); 605 1, GNUNET_NO);
600 return 0; 606 return 0; // FIXME necessary?
601 } 607 }
602#if DEBUG_NSE 608#if DEBUG_NSE
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -713,15 +719,17 @@ schedule_current_round (void *cls, const GNUNET_HashCode * key, void *value)
713 struct NSEPeerEntry *peer_entry = value; 719 struct NSEPeerEntry *peer_entry = value;
714 struct GNUNET_TIME_Relative delay; 720 struct GNUNET_TIME_Relative delay;
715 721
716 if (peer_entry->th != NULL) 722 if (NULL != peer_entry->th)
717 { 723 {
718 peer_entry->previous_round = GNUNET_NO; 724 peer_entry->previous_round = GNUNET_NO;
725 peer_entry->where = __FUNCTION__;
719 return GNUNET_OK; 726 return GNUNET_OK;
720 } 727 }
721 if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) 728 if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task)
722 { 729 {
723 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); 730 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
724 peer_entry->previous_round = GNUNET_NO; 731 peer_entry->previous_round = GNUNET_NO;
732 peer_entry->where = __FUNCTION__;
725 } 733 }
726#if ENABLE_HISTOGRAM 734#if ENABLE_HISTOGRAM
727 if (peer_entry->received_messages > 1) 735 if (peer_entry->received_messages > 1)
@@ -979,8 +987,8 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value)
979 { 987 {
980 /* still stuck in previous round, no point to update, check that 988 /* still stuck in previous round, no point to update, check that
981 * we are active here though... */ 989 * we are active here though... */
982 GNUNET_break (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK || 990 GNUNET_break (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task ||
983 peer_entry->th != NULL); 991 NULL != peer_entry->th);
984 return GNUNET_OK; 992 return GNUNET_OK;
985 } 993 }
986 if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) 994 if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)
@@ -1118,8 +1126,10 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
1118 } 1126 }
1119 if (matching_bits < ntohl (size_estimate_messages[idx].matching_bits)) 1127 if (matching_bits < ntohl (size_estimate_messages[idx].matching_bits))
1120 { 1128 {
1121 if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) 1129 if ((idx < estimate_index) && (peer_entry->previous_round == GNUNET_YES)) {
1122 peer_entry->previous_round = GNUNET_NO; 1130 peer_entry->previous_round = GNUNET_NO;
1131 peer_entry->where = __FUNCTION__ ;
1132 }
1123 /* push back our result now, that peer is spreading bad information... */ 1133 /* push back our result now, that peer is spreading bad information... */
1124 if (NULL == peer_entry->th) 1134 if (NULL == peer_entry->th)
1125 { 1135 {
@@ -1182,7 +1192,8 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
1182 1192
1183 1193
1184/** 1194/**
1185 * Method called whenever a peer connects. 1195 * Method called whenever a peer connects. Sets up the PeerEntry and
1196 * schedules the initial size info transmission to this peer.
1186 * 1197 *
1187 * @param cls closure 1198 * @param cls closure
1188 * @param peer peer identity this notification is about 1199 * @param peer peer identity this notification is about
@@ -1209,12 +1220,14 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
1209 peer_entry->transmit_task = 1220 peer_entry->transmit_task =
1210 GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, 1221 GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb,
1211 peer_entry); 1222 peer_entry);
1223 peer_entry->where = "core connect";
1212 GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); 1224 GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO);
1213} 1225}
1214 1226
1215 1227
1216/** 1228/**
1217 * Method called whenever a peer disconnects. 1229 * Method called whenever a peer disconnects. Deletes the PeerEntry and cancels
1230 * any pending transmission requests to that peer.
1218 * 1231 *
1219 * @param cls closure 1232 * @param cls closure
1220 * @param peer peer identity this notification is about 1233 * @param peer peer identity this notification is about
@@ -1237,8 +1250,10 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
1237 GNUNET_assert (GNUNET_YES == 1250 GNUNET_assert (GNUNET_YES ==
1238 GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey, 1251 GNUNET_CONTAINER_multihashmap_remove (peers, &peer->hashPubKey,
1239 pos)); 1252 pos));
1240 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) 1253 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) {
1241 GNUNET_SCHEDULER_cancel (pos->transmit_task); 1254 GNUNET_SCHEDULER_cancel (pos->transmit_task);
1255 pos->transmit_task = GNUNET_SCHEDULER_NO_TASK;
1256 }
1242 if (pos->th != NULL) 1257 if (pos->th != NULL)
1243 { 1258 {
1244 GNUNET_CORE_notify_transmit_ready_cancel (pos->th); 1259 GNUNET_CORE_notify_transmit_ready_cancel (pos->th);