diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-19 21:36:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-19 21:36:02 +0000 |
commit | 3a6966e9fbd995dbdea20484d843a34f04589a9e (patch) | |
tree | 7923962712e49e5e995b16d9d6fae3109ff11f24 /src/nse | |
parent | 3d08414cb6729815c74c895ff6f7b36c4e954989 (diff) | |
download | gnunet-3a6966e9fbd995dbdea20484d843a34f04589a9e.tar.gz gnunet-3a6966e9fbd995dbdea20484d843a34f04589a9e.zip |
-hopefully fixing #1997, also renaming function to avoid double-use of 'transmit_task' identifier; minor clean up of assertion code
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 5bf320ac4..a7c31c49c 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -529,7 +529,7 @@ get_transmit_delay (int round_offset) | |||
529 | * @param tc scheduler context | 529 | * @param tc scheduler context |
530 | */ | 530 | */ |
531 | static void | 531 | static void |
532 | transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 532 | transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
533 | 533 | ||
534 | 534 | ||
535 | /** | 535 | /** |
@@ -560,7 +560,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
560 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; | 560 | idx = (idx + HISTORY_SIZE - 1) % HISTORY_SIZE; |
561 | peer_entry->previous_round = GNUNET_YES; | 561 | peer_entry->previous_round = GNUNET_YES; |
562 | peer_entry->transmit_task = | 562 | peer_entry->transmit_task = |
563 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), &transmit_task, | 563 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (0), &transmit_task_cb, |
564 | peer_entry); | 564 | peer_entry); |
565 | } | 565 | } |
566 | if ((ntohl (size_estimate_messages[idx].hop_count) == 0) && | 566 | if ((ntohl (size_estimate_messages[idx].hop_count) == 0) && |
@@ -605,7 +605,7 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
605 | * @param tc scheduler context | 605 | * @param tc scheduler context |
606 | */ | 606 | */ |
607 | static void | 607 | static void |
608 | transmit_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 608 | transmit_task_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
609 | { | 609 | { |
610 | struct NSEPeerEntry *peer_entry = cls; | 610 | struct NSEPeerEntry *peer_entry = cls; |
611 | 611 | ||
@@ -701,7 +701,7 @@ schedule_current_round (void *cls, const GNUNET_HashCode * key, void *value) | |||
701 | delay = | 701 | delay = |
702 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); | 702 | get_transmit_delay ((peer_entry->previous_round == GNUNET_NO) ? -1 : 0); |
703 | peer_entry->transmit_task = | 703 | peer_entry->transmit_task = |
704 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task, peer_entry); | 704 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry); |
705 | return GNUNET_OK; | 705 | return GNUNET_OK; |
706 | } | 706 | } |
707 | 707 | ||
@@ -942,8 +942,7 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) | |||
942 | { | 942 | { |
943 | /* still stuck in previous round, no point to update, check that | 943 | /* still stuck in previous round, no point to update, check that |
944 | * we are active here though... */ | 944 | * we are active here though... */ |
945 | GNUNET_break ((peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) || | 945 | GNUNET_break ((peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK)); |
946 | (peer_entry->th != NULL)); | ||
947 | return GNUNET_OK; | 946 | return GNUNET_OK; |
948 | } | 947 | } |
949 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 948 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -953,7 +952,7 @@ update_flood_times (void *cls, const GNUNET_HashCode * key, void *value) | |||
953 | } | 952 | } |
954 | delay = get_transmit_delay (0); | 953 | delay = get_transmit_delay (0); |
955 | peer_entry->transmit_task = | 954 | peer_entry->transmit_task = |
956 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task, peer_entry); | 955 | GNUNET_SCHEDULER_add_delayed (delay, &transmit_task_cb, peer_entry); |
957 | return GNUNET_OK; | 956 | return GNUNET_OK; |
958 | } | 957 | } |
959 | 958 | ||
@@ -1085,6 +1084,10 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1085 | peer_entry->previous_round = GNUNET_YES; | 1084 | peer_entry->previous_round = GNUNET_YES; |
1086 | return GNUNET_OK; | 1085 | return GNUNET_OK; |
1087 | } | 1086 | } |
1087 | /* even if we didn't talk to this peer in the previous round, we should | ||
1088 | no longer send it stale information as it told us about the current | ||
1089 | round! */ | ||
1090 | peer_entry->previous_round = GNUNET_YES; | ||
1088 | /* got up-to-date information for current round, cancel transmission altogether */ | 1091 | /* got up-to-date information for current round, cancel transmission altogether */ |
1089 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) | 1092 | if (GNUNET_SCHEDULER_NO_TASK != peer_entry->transmit_task) |
1090 | { | 1093 | { |
@@ -1108,7 +1111,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1108 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) | 1111 | if (peer_entry->transmit_task != GNUNET_SCHEDULER_NO_TASK) |
1109 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); | 1112 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
1110 | peer_entry->transmit_task = | 1113 | peer_entry->transmit_task = |
1111 | GNUNET_SCHEDULER_add_now (&transmit_task, peer_entry); | 1114 | GNUNET_SCHEDULER_add_now (&transmit_task_cb, peer_entry); |
1112 | } | 1115 | } |
1113 | /* Not closer than our most recent message, no need to do work here */ | 1116 | /* Not closer than our most recent message, no need to do work here */ |
1114 | GNUNET_STATISTICS_update (stats, | 1117 | GNUNET_STATISTICS_update (stats, |
@@ -1167,7 +1170,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1167 | peer_entry, | 1170 | peer_entry, |
1168 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1171 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1169 | peer_entry->transmit_task = | 1172 | peer_entry->transmit_task = |
1170 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task, | 1173 | GNUNET_SCHEDULER_add_delayed (get_transmit_delay (-1), &transmit_task_cb, |
1171 | peer_entry); | 1174 | peer_entry); |
1172 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); | 1175 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); |
1173 | } | 1176 | } |