aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_twopeer_path_tracking.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/dht/test_dht_twopeer_path_tracking.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/dht/test_dht_twopeer_path_tracking.c')
-rw-r--r--src/dht/test_dht_twopeer_path_tracking.c74
1 files changed, 31 insertions, 43 deletions
diff --git a/src/dht/test_dht_twopeer_path_tracking.c b/src/dht/test_dht_twopeer_path_tracking.c
index ab0b1edd2..9985939ae 100644
--- a/src/dht/test_dht_twopeer_path_tracking.c
+++ b/src/dht/test_dht_twopeer_path_tracking.c
@@ -188,8 +188,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
188 * @param data pointer to the result data 188 * @param data pointer to the result data
189 */ 189 */
190void 190void
191get_result_iterator (void *cls, 191get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
192 struct GNUNET_TIME_Absolute exp,
193 const GNUNET_HashCode * key, 192 const GNUNET_HashCode * key,
194 const struct GNUNET_PeerIdentity *const *get_path, 193 const struct GNUNET_PeerIdentity *const *get_path,
195 const struct GNUNET_PeerIdentity *const *put_path, 194 const struct GNUNET_PeerIdentity *const *put_path,
@@ -262,9 +261,9 @@ static void
262put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 261put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
263{ 262{
264 GNUNET_SCHEDULER_cancel (die_task); 263 GNUNET_SCHEDULER_cancel (die_task);
265 die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, 264 die_task =
266 &end_badly, 265 GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly,
267 "waiting for get response (data not found)"); 266 "waiting for get response (data not found)");
268 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 267 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
269 (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); 268 (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL);
270} 269}
@@ -282,13 +281,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
282 memset (data, 43, sizeof (data)); 281 memset (data, 43, sizeof (data));
283 282
284 /* Insert the data at the first peer */ 283 /* Insert the data at the first peer */
285 GNUNET_DHT_put (peer1dht, 284 GNUNET_DHT_put (peer1dht, &key, DEFAULT_PUT_REPLICATION,
286 &key, 285 GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_BLOCK_TYPE_TEST,
287 DEFAULT_PUT_REPLICATION, 286 sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS,
288 GNUNET_DHT_RO_RECORD_ROUTE,
289 GNUNET_BLOCK_TYPE_TEST,
290 sizeof (data), data,
291 GNUNET_TIME_UNIT_FOREVER_ABS,
292 GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); 287 GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL);
293} 288}
294 289
@@ -302,10 +297,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
302 * failure (peers failed to connect). 297 * failure (peers failed to connect).
303 */ 298 */
304void 299void
305topology_callback (void *cls, 300topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
306 const struct GNUNET_PeerIdentity *first, 301 const struct GNUNET_PeerIdentity *second, uint32_t distance,
307 const struct GNUNET_PeerIdentity *second,
308 uint32_t distance,
309 const struct GNUNET_CONFIGURATION_Handle *first_cfg, 302 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
310 const struct GNUNET_CONFIGURATION_Handle *second_cfg, 303 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
311 struct GNUNET_TESTING_Daemon *first_daemon, 304 struct GNUNET_TESTING_Daemon *first_daemon,
@@ -339,8 +332,8 @@ topology_callback (void *cls,
339 total_connections); 332 total_connections);
340#endif 333#endif
341 GNUNET_SCHEDULER_cancel (die_task); 334 GNUNET_SCHEDULER_cancel (die_task);
342 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 335 die_task =
343 &end_badly, "from test gets"); 336 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets");
344 337
345 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 338 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
346 (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); 339 (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL);
@@ -367,8 +360,7 @@ topology_callback (void *cls,
367 * @param emsg NULL if peer started, non-NULL on error 360 * @param emsg NULL if peer started, non-NULL on error
368 */ 361 */
369static void 362static void
370peers_started_callback (void *cls, 363peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id,
371 const struct GNUNET_PeerIdentity *id,
372 const struct GNUNET_CONFIGURATION_Handle *cfg, 364 const struct GNUNET_CONFIGURATION_Handle *cfg,
373 struct GNUNET_TESTING_Daemon *d, const char *emsg) 365 struct GNUNET_TESTING_Daemon *d, const char *emsg)
374{ 366{
@@ -415,12 +407,10 @@ peers_started_callback (void *cls,
415 if ((pg != NULL)) /* Sanity check */ 407 if ((pg != NULL)) /* Sanity check */
416 { 408 {
417 /* Connect peers in a "straight line" topology, return the number of expected connections */ 409 /* Connect peers in a "straight line" topology, return the number of expected connections */
418 expected_connections = GNUNET_TESTING_connect_topology (pg, 410 expected_connections =
419 GNUNET_TESTING_TOPOLOGY_LINE, 411 GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE,
420 GNUNET_TESTING_TOPOLOGY_OPTION_ALL, 412 GNUNET_TESTING_TOPOLOGY_OPTION_ALL,
421 0.0, 413 0.0, TIMEOUT, 2, NULL, NULL);
422 TIMEOUT,
423 2, NULL, NULL);
424 } 414 }
425 415
426 /* Cancel current timeout fail task */ 416 /* Cancel current timeout fail task */
@@ -431,17 +421,16 @@ peers_started_callback (void *cls,
431 "from connect topology (bad return)"); 421 "from connect topology (bad return)");
432 422
433 /* Schedule timeout on failure task */ 423 /* Schedule timeout on failure task */
434 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 424 die_task =
435 &end_badly, 425 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
436 "from connect topology (timeout)"); 426 "from connect topology (timeout)");
437 ok = 0; 427 ok = 0;
438 } 428 }
439} 429}
440 430
441static void 431static void
442run (void *cls, 432run (void *cls, char *const *args, const char *cfgfile,
443 char *const *args, 433 const struct GNUNET_CONFIGURATION_Handle *cfg)
444 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
445{ 434{
446 435
447 /* Get path from configuration file */ 436 /* Get path from configuration file */
@@ -463,20 +452,18 @@ run (void *cls,
463 peers_left = num_peers; 452 peers_left = num_peers;
464 453
465 /* Set up a task to end testing if peer start fails */ 454 /* Set up a task to end testing if peer start fails */
466 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 455 die_task =
467 &end_badly, 456 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
468 "didn't start all daemons in reasonable amount of time!!!"); 457 "didn't start all daemons in reasonable amount of time!!!");
469 458
470 /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ 459 /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */
471 /* Read the API documentation for other parameters! */ 460 /* Read the API documentation for other parameters! */
472 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ 461 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */
473 peers_left, /* Number of outstanding connections */ 462 peers_left, /* Number of outstanding connections */
474 peers_left, /* Number of parallel ssh connections, or peers being started at once */ 463 peers_left, /* Number of parallel ssh connections, or peers being started at once */
475 TIMEOUT, 464 TIMEOUT, NULL, NULL,
476 NULL, 465 &peers_started_callback, NULL,
477 NULL, 466 &topology_callback, NULL, NULL);
478 &peers_started_callback,
479 NULL, &topology_callback, NULL, NULL);
480 467
481} 468}
482 469
@@ -498,9 +485,10 @@ check ()
498 GNUNET_GETOPT_OPTION_END 485 GNUNET_GETOPT_OPTION_END
499 }; 486 };
500 /* Run the run function as a new program */ 487 /* Run the run function as a new program */
501 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 488 ret =
502 argv, "test-dht-twopeer-put-get", "nohelp", 489 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
503 options, &run, &ok); 490 "test-dht-twopeer-put-get", "nohelp", options, &run,
491 &ok);
504 if (ret != GNUNET_OK) 492 if (ret != GNUNET_OK)
505 { 493 {
506 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 494 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,