aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist/gnunet-daemon-hostlist.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-04-15 16:29:55 +0000
committerChristian Grothoff <christian@grothoff.org>2010-04-15 16:29:55 +0000
commitbf73f35e6102aa4152f6af9e9ae0b3e571edeb1c (patch)
tree857d06c2161dc9dc149e3d9ee7631c2ee5829e28 /src/hostlist/gnunet-daemon-hostlist.c
parent9e328007bd59ec2ac99a198ecbd6cd863fcd27a8 (diff)
downloadgnunet-bf73f35e6102aa4152f6af9e9ae0b3e571edeb1c.tar.gz
gnunet-bf73f35e6102aa4152f6af9e9ae0b3e571edeb1c.zip
cleaning
Diffstat (limited to 'src/hostlist/gnunet-daemon-hostlist.c')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 3622e0e8f..c06ee5f56 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -168,21 +168,11 @@ static int advertisement_handler (void *cls,
168 struct GNUNET_TIME_Relative latency, 168 struct GNUNET_TIME_Relative latency,
169 uint32_t distance) 169 uint32_t distance)
170{ 170{
171 if ( !learning ) 171 GNUNET_assert (NULL != client_adv_handler);
172 { 172 return (*client_adv_handler) (cls, peer, message, latency, distance);
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
174 "Recieved hostlist advertisement, but I am not learning!\n");
175 return GNUNET_NO;
176 }
177
178 if (learning && (NULL != client_adv_handler))
179 {
180 (*client_adv_handler) (cls, peer, message, latency, distance);
181 return GNUNET_YES;
182 }
183 return GNUNET_NO;
184} 173}
185 174
175
186/** 176/**
187 * Method called whenever a given peer connects. Wrapper to call both client's and server's functions 177 * Method called whenever a given peer connects. Wrapper to call both client's and server's functions
188 * 178 *
@@ -260,14 +250,22 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
260} 250}
261 251
262/** 252/**
263 * List of handlers for the messages understood by this 253 * List of handlers if we are learning.
264 * service.
265 */ 254 */
266static struct GNUNET_CORE_MessageHandler handlers[] = { 255static struct GNUNET_CORE_MessageHandler learn_handlers[] = {
267 { &advertisement_handler, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0}, 256 { &advertisement_handler, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0},
257 { NULL, 0, 0 }
258};
259
260
261/**
262 * List of handlers if we are not learning.
263 */
264static struct GNUNET_CORE_MessageHandler no_learn_handlers[] = {
268 { NULL, 0, 0 } 265 { NULL, 0, 0 }
269}; 266};
270 267
268
271/** 269/**
272 * Main function that will be run. 270 * Main function that will be run.
273 * 271 *
@@ -295,13 +293,13 @@ run (void *cls,
295 stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg); 293 stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg);
296 294
297 core = GNUNET_CORE_connect (sched, cfg, 295 core = GNUNET_CORE_connect (sched, cfg,
298 GNUNET_TIME_UNIT_FOREVER_REL, 296 GNUNET_TIME_UNIT_FOREVER_REL,
299 NULL, 297 NULL,
300 &core_init, 298 &core_init,
301 NULL, &connect_handler, &disconnect_handler, 299 NULL, &connect_handler, &disconnect_handler,
302 NULL, GNUNET_NO, 300 NULL, GNUNET_NO,
303 NULL, GNUNET_NO, 301 NULL, GNUNET_NO,
304 handlers); 302 learning? learn_handlers : no_learn_handlers);
305 303
306 if (bootstrapping) 304 if (bootstrapping)
307 { 305 {
@@ -312,10 +310,6 @@ run (void *cls,
312 { 310 {
313 GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh, advertising ); 311 GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh, advertising );
314 } 312 }
315 if (learning)
316 {
317
318 }
319 313
320 GNUNET_SCHEDULER_add_delayed (sched, 314 GNUNET_SCHEDULER_add_delayed (sched,
321 GNUNET_TIME_UNIT_FOREVER_REL, 315 GNUNET_TIME_UNIT_FOREVER_REL,