diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-15 10:07:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-15 10:07:52 +0000 |
commit | 4d84bdf0cb7e3368948d77c7183ec127c2e9306d (patch) | |
tree | fd3c54f737c610944618001377aaae339057c9bf /src/topology | |
parent | e379362f05a8f3ad770e54c165ab1cfb9a61a2ce (diff) | |
download | gnunet-4d84bdf0cb7e3368948d77c7183ec127c2e9306d.tar.gz gnunet-4d84bdf0cb7e3368948d77c7183ec127c2e9306d.zip |
adjust code to new peerinfo API
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 40582029d..880f8603c 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -219,10 +219,16 @@ static unsigned int friend_count; | |||
219 | static int autoconnect; | 219 | static int autoconnect; |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Are we currently having a request pending with | 222 | * Non-NULL if we are currently having a request pending with |
223 | * PEERINFO asking for HELLOs for advertising? | 223 | * PEERINFO asking for HELLOs for advertising? |
224 | */ | 224 | */ |
225 | static int hello_gathering_active; | 225 | static struct GNUNET_PEERINFO_IteratorContext *pitr; |
226 | |||
227 | /** | ||
228 | * Non-NULL if we are currently having a request pending with | ||
229 | * PEERINFO looking for more peers to connect to. | ||
230 | */ | ||
231 | static struct GNUNET_PEERINFO_IteratorContext *pitr_more; | ||
226 | 232 | ||
227 | 233 | ||
228 | 234 | ||
@@ -642,6 +648,7 @@ process_peer (void *cls, | |||
642 | 648 | ||
643 | if (peer == NULL) | 649 | if (peer == NULL) |
644 | { | 650 | { |
651 | pitr_more = NULL; | ||
645 | /* last call, schedule 'find_more_peers' again... */ | 652 | /* last call, schedule 'find_more_peers' again... */ |
646 | if (0 != (GNUNET_SCHEDULER_get_reason (sched) & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 653 | if (0 != (GNUNET_SCHEDULER_get_reason (sched) & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
647 | { | 654 | { |
@@ -814,11 +821,11 @@ find_more_peers (void *cls, | |||
814 | target_connection_count, | 821 | target_connection_count, |
815 | friend_count); | 822 | friend_count); |
816 | #endif | 823 | #endif |
817 | GNUNET_PEERINFO_for_all (cfg, | 824 | pitr_more = GNUNET_PEERINFO_iterate (cfg, |
818 | sched, | 825 | sched, |
819 | NULL, | 826 | NULL, |
820 | 0, GNUNET_TIME_UNIT_FOREVER_REL, | 827 | 0, GNUNET_TIME_UNIT_FOREVER_REL, |
821 | &process_peer, NULL); | 828 | &process_peer, NULL); |
822 | } | 829 | } |
823 | 830 | ||
824 | 831 | ||
@@ -1036,7 +1043,7 @@ gather_hello_callback (void *cls, | |||
1036 | { | 1043 | { |
1037 | if (peer == NULL) | 1044 | if (peer == NULL) |
1038 | { | 1045 | { |
1039 | hello_gathering_active = GNUNET_NO; | 1046 | pitr = NULL; |
1040 | return; | 1047 | return; |
1041 | } | 1048 | } |
1042 | #if DEBUG_TOPOLOGY | 1049 | #if DEBUG_TOPOLOGY |
@@ -1139,7 +1146,7 @@ hello_advertising (void *cls, | |||
1139 | #endif | 1146 | #endif |
1140 | return size; | 1147 | return size; |
1141 | } | 1148 | } |
1142 | if ( (GNUNET_NO == hello_gathering_active) && | 1149 | if ( (NULL == pitr) && |
1143 | (GNUNET_TIME_absolute_get_duration (last_hello_gather_time).value > | 1150 | (GNUNET_TIME_absolute_get_duration (last_hello_gather_time).value > |
1144 | MIN_HELLO_GATHER_DELAY.value) ) | 1151 | MIN_HELLO_GATHER_DELAY.value) ) |
1145 | { | 1152 | { |
@@ -1149,13 +1156,12 @@ hello_advertising (void *cls, | |||
1149 | "HELLO", | 1156 | "HELLO", |
1150 | "PEERINFO"); | 1157 | "PEERINFO"); |
1151 | #endif | 1158 | #endif |
1152 | hello_gathering_active = GNUNET_YES; | ||
1153 | last_hello_gather_time = GNUNET_TIME_absolute_get(); | 1159 | last_hello_gather_time = GNUNET_TIME_absolute_get(); |
1154 | GNUNET_PEERINFO_for_all (cfg, | 1160 | pitr = GNUNET_PEERINFO_iterate (cfg, |
1155 | sched, | 1161 | sched, |
1156 | NULL, | 1162 | NULL, |
1157 | 0, GNUNET_TIME_UNIT_FOREVER_REL, | 1163 | 0, GNUNET_TIME_UNIT_FOREVER_REL, |
1158 | &gather_hello_callback, NULL); | 1164 | &gather_hello_callback, NULL); |
1159 | } | 1165 | } |
1160 | return 0; | 1166 | return 0; |
1161 | } | 1167 | } |
@@ -1175,6 +1181,16 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1175 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 1181 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); |
1176 | peerinfo_notify = NULL; | 1182 | peerinfo_notify = NULL; |
1177 | } | 1183 | } |
1184 | if (NULL != pitr) | ||
1185 | { | ||
1186 | GNUNET_PEERINFO_iterate_cancel (pitr); | ||
1187 | pitr = NULL; | ||
1188 | } | ||
1189 | if (NULL != pitr_more) | ||
1190 | { | ||
1191 | GNUNET_PEERINFO_iterate_cancel (pitr_more); | ||
1192 | pitr_more = NULL; | ||
1193 | } | ||
1178 | GNUNET_TRANSPORT_disconnect (transport); | 1194 | GNUNET_TRANSPORT_disconnect (transport); |
1179 | transport = NULL; | 1195 | transport = NULL; |
1180 | if (handle != NULL) | 1196 | if (handle != NULL) |