aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-19 09:34:56 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-19 09:34:56 +0000
commitbef20834523944b625a550e5a14ad94fbbcc6e6e (patch)
treeaa26b8e6cd1174ba0aa15b0aba7096afb0006b0e /src/fs
parent5ecf0c3e1df10fdce2dbae9efc75d59a13aefb58 (diff)
downloadgnunet-bef20834523944b625a550e5a14ad94fbbcc6e6e.tar.gz
gnunet-bef20834523944b625a550e5a14ad94fbbcc6e6e.zip
fixes
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_test_lib.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index b0776e736..dd646eafe 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -39,6 +39,12 @@ struct GNUNET_FS_TestDaemon
39{ 39{
40 40
41 /** 41 /**
42 * Global configuration, only stored in first test daemon,
43 * otherwise NULL.
44 */
45 struct GNUNET_CONFIGURATION_Handle *gcfg;
46
47 /**
42 * Handle to the file sharing context using this daemon. 48 * Handle to the file sharing context using this daemon.
43 */ 49 */
44 struct GNUNET_FS_Handle *fs; 50 struct GNUNET_FS_Handle *fs;
@@ -140,15 +146,17 @@ struct GNUNET_FS_TestDaemon
140/** 146/**
141 * Check whether peers successfully shut down. 147 * Check whether peers successfully shut down.
142 */ 148 */
143void shutdown_callback (void *cls, 149static void
144 const char *emsg) 150shutdown_callback (void *cls,
151 const char *emsg)
145{ 152{
153 struct GNUNET_CONFIGURATION_Handle *gcfg = cls;
154
146 if (emsg != NULL) 155 if (emsg != NULL)
147 { 156 {
148#if VERBOSE 157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 158 "Shutdown of peers failed: %s\n",
150 "Shutdown of peers failed!\n"); 159 emsg);
151#endif
152 } 160 }
153 else 161 else
154 { 162 {
@@ -157,8 +165,11 @@ void shutdown_callback (void *cls,
157 "All peers successfully shut down!\n"); 165 "All peers successfully shut down!\n");
158#endif 166#endif
159 } 167 }
168 if (gcfg != NULL)
169 GNUNET_CONFIGURATION_destroy (gcfg);
160} 170}
161 171
172
162static void 173static void
163report_uri (void *cls, 174report_uri (void *cls,
164 const struct GNUNET_SCHEDULER_TaskContext *tc) 175 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -195,6 +206,7 @@ report_success (void *cls,
195 daemon->download_sched = NULL; 206 daemon->download_sched = NULL;
196} 207}
197 208
209
198static void* 210static void*
199progress_cb (void *cls, 211progress_cb (void *cls,
200 const struct GNUNET_FS_ProgressInfo *info) 212 const struct GNUNET_FS_ProgressInfo *info)
@@ -303,7 +315,7 @@ notify_running (void *cls,
303 sctx->cont, 315 sctx->cont,
304 sctx->cont_cls, 316 sctx->cont_cls,
305 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 317 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
306 GNUNET_CONFIGURATION_destroy (sctx->cfg); 318 sctx->daemons[0]->gcfg = sctx->cfg;
307 GNUNET_SCHEDULER_cancel (sctx->sched, 319 GNUNET_SCHEDULER_cancel (sctx->sched,
308 sctx->timeout_task); 320 sctx->timeout_task);
309 for (i=0;i<sctx->total;i++) 321 for (i=0;i<sctx->total;i++)
@@ -328,6 +340,8 @@ start_timeout (void *cls,
328 struct StartContext *sctx = cls; 340 struct StartContext *sctx = cls;
329 unsigned int i; 341 unsigned int i;
330 342
343 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
344 "Timeout while trying to start daemons\n");
331 GNUNET_TESTING_daemons_stop (sctx->group, 345 GNUNET_TESTING_daemons_stop (sctx->group,
332 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), 346 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
333 &shutdown_callback, 347 &shutdown_callback,
@@ -420,6 +434,7 @@ struct ConnectContext
420 void *cont_cls; 434 void *cont_cls;
421}; 435};
422 436
437
423/** 438/**
424 * Prototype of a function that will be called whenever 439 * Prototype of a function that will be called whenever
425 * two daemons are connected by the testing library. 440 * two daemons are connected by the testing library.
@@ -449,7 +464,7 @@ notify_connection (void *cls,
449 464
450 if (emsg != NULL) 465 if (emsg != NULL)
451 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 466 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
452 _("Failed to connect peers: %s\n"), 467 "Failed to connect peers: %s\n",
453 emsg); 468 emsg);
454 GNUNET_SCHEDULER_add_continuation (cc->sched, 469 GNUNET_SCHEDULER_add_continuation (cc->sched,
455 cc->cont, 470 cc->cont,
@@ -536,9 +551,11 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
536{ 551{
537 unsigned int i; 552 unsigned int i;
538 struct GNUNET_TESTING_PeerGroup *pg; 553 struct GNUNET_TESTING_PeerGroup *pg;
554 struct GNUNET_CONFIGURATION_Handle *gcfg;
539 555
540 GNUNET_assert (total > 0); 556 GNUNET_assert (total > 0);
541 pg = daemons[0]->group; 557 pg = daemons[0]->group;
558 gcfg = daemons[0]->gcfg;
542 for (i=0;i<total;i++) 559 for (i=0;i<total;i++)
543 { 560 {
544 if (daemons[i]->fs != NULL) 561 if (daemons[i]->fs != NULL)
@@ -548,7 +565,10 @@ GNUNET_FS_TEST_daemons_stop (struct GNUNET_SCHEDULER_Handle *sched,
548 GNUNET_free (daemons[i]); 565 GNUNET_free (daemons[i]);
549 daemons[i] = NULL; 566 daemons[i] = NULL;
550 } 567 }
551 GNUNET_TESTING_daemons_stop (pg, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30), &shutdown_callback, NULL); 568 GNUNET_TESTING_daemons_stop (pg,
569 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
570 &shutdown_callback,
571 gcfg);
552} 572}
553 573
554 574
@@ -558,7 +578,9 @@ publish_timeout (void *cls,
558{ 578{
559 struct GNUNET_FS_TestDaemon *daemon = cls; 579 struct GNUNET_FS_TestDaemon *daemon = cls;
560 GNUNET_FS_TEST_UriContinuation cont; 580 GNUNET_FS_TEST_UriContinuation cont;
561 581
582 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
583 "Timeout while trying to publish data\n");
562 cont = daemon->publish_cont; 584 cont = daemon->publish_cont;
563 daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK; 585 daemon->publish_timeout_task = GNUNET_SCHEDULER_NO_TASK;
564 daemon->publish_cont = NULL; 586 daemon->publish_cont = NULL;
@@ -581,6 +603,8 @@ file_generator (void *cls,
581 uint8_t *cbuf = buf; 603 uint8_t *cbuf = buf;
582 int mod; 604 int mod;
583 605
606 if (buf == NULL)
607 return 0;
584 for (pos=0;pos<8;pos++) 608 for (pos=0;pos<8;pos++)
585 cbuf[pos] = (uint8_t) (offset >> pos*8); 609 cbuf[pos] = (uint8_t) (offset >> pos*8);
586 for (pos=8;pos<max;pos++) 610 for (pos=8;pos<max;pos++)
@@ -659,6 +683,8 @@ download_timeout (void *cls,
659{ 683{
660 struct GNUNET_FS_TestDaemon *daemon = cls; 684 struct GNUNET_FS_TestDaemon *daemon = cls;
661 685
686 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
687 "Timeout while trying to download file\n");
662 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; 688 daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK;
663 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES); 689 GNUNET_FS_download_stop (daemon->download_context, GNUNET_YES);
664 daemon->download_context = NULL; 690 daemon->download_context = NULL;