aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-02-01 08:48:47 +0000
committerChristian Grothoff <christian@grothoff.org>2013-02-01 08:48:47 +0000
commit309276a88d1e57dffbea0014dc0708726c2e9376 (patch)
tree285ffccfe3cf9f69c7f3f537d80e473e8f087cc9 /src/fs
parent4785f9c53cad18c14a20e9341b86b97f1021a574 (diff)
downloadgnunet-309276a88d1e57dffbea0014dc0708726c2e9376.tar.gz
gnunet-309276a88d1e57dffbea0014dc0708726c2e9376.zip
-fix non-terminating index test --- do not remove file early
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_test_lib.c13
-rw-r--r--src/fs/fs_test_lib.h5
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p.c16
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_respect.c42
-rw-r--r--src/fs/test_fs_test_lib.c12
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c33
-rw-r--r--src/fs/test_gnunet_service_fs_p2p.c13
7 files changed, 107 insertions, 27 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c
index 52f14c00d..758220f5f 100644
--- a/src/fs/fs_test_lib.c
+++ b/src/fs/fs_test_lib.c
@@ -190,9 +190,14 @@ report_uri (void *cls,
190 190
191 GNUNET_FS_publish_stop (po->publish_context); 191 GNUNET_FS_publish_stop (po->publish_context);
192 GNUNET_TESTBED_operation_done (po->fs_op); 192 GNUNET_TESTBED_operation_done (po->fs_op);
193 po->publish_cont (po->publish_cont_cls, po->publish_uri); 193 po->publish_cont (po->publish_cont_cls,
194 po->publish_uri,
195 (GNUNET_YES == po->do_index)
196 ? po->publish_tmp_file
197 : NULL);
194 GNUNET_FS_uri_destroy (po->publish_uri); 198 GNUNET_FS_uri_destroy (po->publish_uri);
195 (void) GNUNET_DISK_directory_remove (po->publish_tmp_file); 199 if (GNUNET_YES != po->do_index)
200 (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
196 GNUNET_free_non_null (po->publish_tmp_file); 201 GNUNET_free_non_null (po->publish_tmp_file);
197 GNUNET_free (po); 202 GNUNET_free (po);
198} 203}
@@ -217,7 +222,7 @@ publish_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
217 else 222 else
218 GNUNET_TESTBED_operation_done (po->fs_op); 223 GNUNET_TESTBED_operation_done (po->fs_op);
219 GNUNET_FS_publish_stop (po->publish_context); 224 GNUNET_FS_publish_stop (po->publish_context);
220 po->publish_cont (po->publish_cont_cls, NULL); 225 po->publish_cont (po->publish_cont_cls, NULL, NULL);
221 (void) GNUNET_DISK_directory_remove (po->publish_tmp_file); 226 (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
222 GNUNET_free_non_null (po->publish_tmp_file); 227 GNUNET_free_non_null (po->publish_tmp_file);
223 GNUNET_free (po); 228 GNUNET_free (po);
@@ -370,7 +375,7 @@ publish_fs_connect_complete_cb (void *cls,
370 { 375 {
371 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to FS for publishing: %s\n", emsg); 376 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to FS for publishing: %s\n", emsg);
372 po->publish_cont (po->publish_cont_cls, 377 po->publish_cont (po->publish_cont_cls,
373 NULL); 378 NULL, NULL);
374 GNUNET_TESTBED_operation_done (po->fs_op); 379 GNUNET_TESTBED_operation_done (po->fs_op);
375 GNUNET_free (po); 380 GNUNET_free (po);
376 return; 381 return;
diff --git a/src/fs/fs_test_lib.h b/src/fs/fs_test_lib.h
index d00c21b1e..679e0745c 100644
--- a/src/fs/fs_test_lib.h
+++ b/src/fs/fs_test_lib.h
@@ -39,10 +39,13 @@
39 * 39 *
40 * @param cls closure (user defined) 40 * @param cls closure (user defined)
41 * @param uri a URI, NULL for errors 41 * @param uri a URI, NULL for errors
42 * @param fn name of the file on disk to be removed upon
43 * completion, or NULL for inserted files (also NULL on error)
42 */ 44 */
43typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls, 45typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls,
44 const struct GNUNET_FS_Uri * 46 const struct GNUNET_FS_Uri *
45 uri); 47 uri,
48 const char *fn);
46 49
47 50
48/** 51/**
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c
index 6c84d1545..89db80c0b 100644
--- a/src/fs/perf_gnunet_service_fs_p2p.c
+++ b/src/fs/perf_gnunet_service_fs_p2p.c
@@ -234,18 +234,25 @@ stat_run (void *cls,
234static void 234static void
235do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 235do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
236{ 236{
237 char *fn = cls;
237 struct GNUNET_TIME_Relative del; 238 struct GNUNET_TIME_Relative del;
238 char *fancy; 239 char *fancy;
239 struct StatMaster *sm; 240 struct StatMaster *sm;
240 241
242 if (NULL != fn)
243 {
244 GNUNET_DISK_directory_remove (fn);
245 GNUNET_free (fn);
246 }
241 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 247 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
242 { 248 {
243 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
244 "Timeout during download, shutting down with error\n"); 250 "Timeout during download, shutting down with error\n");
245 ok = 1; 251 ok = 1;
246 GNUNET_SCHEDULER_shutdown (); 252 GNUNET_SCHEDULER_shutdown ();
247 return; 253 return;
248 } 254 }
255
249 del = GNUNET_TIME_absolute_get_duration (start_time); 256 del = GNUNET_TIME_absolute_get_duration (start_time);
250 if (del.rel_value == 0) 257 if (del.rel_value == 0)
251 del.rel_value = 1; 258 del.rel_value = 1;
@@ -269,7 +276,9 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
269 276
270 277
271static void 278static void
272do_download (void *cls, const struct GNUNET_FS_Uri *uri) 279do_download (void *cls,
280 const struct GNUNET_FS_Uri *uri,
281 const char *fn)
273{ 282{
274 int anonymity; 283 int anonymity;
275 284
@@ -289,7 +298,8 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
289 else 298 else
290 anonymity = 1; 299 anonymity = 1;
291 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE, 300 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE,
292 &do_report, NULL); 301 &do_report,
302 (NULL == fn) ? NULL : GNUNET_strdup (fn));
293} 303}
294 304
295 305
diff --git a/src/fs/perf_gnunet_service_fs_p2p_respect.c b/src/fs/perf_gnunet_service_fs_p2p_respect.c
index 11fb0b540..0a5dc0578 100644
--- a/src/fs/perf_gnunet_service_fs_p2p_respect.c
+++ b/src/fs/perf_gnunet_service_fs_p2p_respect.c
@@ -86,6 +86,9 @@ static struct GNUNET_FS_Uri *uri1;
86 86
87static struct GNUNET_FS_Uri *uri2; 87static struct GNUNET_FS_Uri *uri2;
88 88
89static char *fn1;
90
91static char *fn2;
89 92
90/** 93/**
91 * Master context for 'stat_run'. 94 * Master context for 'stat_run'.
@@ -132,6 +135,23 @@ static struct StatValues stats[] = {
132}; 135};
133 136
134 137
138static void
139cleanup ()
140{
141 GNUNET_SCHEDULER_shutdown ();
142 if (NULL != fn1)
143 {
144 GNUNET_DISK_directory_remove (fn1);
145 GNUNET_free (fn1);
146 }
147 if (NULL != fn2)
148 {
149 GNUNET_DISK_directory_remove (fn2);
150 GNUNET_free (fn2);
151 }
152}
153
154
135/** 155/**
136 * Callback function to process statistic values. 156 * Callback function to process statistic values.
137 * 157 *
@@ -244,7 +264,7 @@ stat_run (void *cls,
244 if (NUM_DAEMONS == sm->daemon) 264 if (NUM_DAEMONS == sm->daemon)
245 { 265 {
246 GNUNET_free (sm); 266 GNUNET_free (sm);
247 GNUNET_SCHEDULER_shutdown (); 267 cleanup ();
248 return; 268 return;
249 } 269 }
250 sm->op = 270 sm->op =
@@ -273,7 +293,7 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
273 "Timeout during download for type `%s', shutting down with error\n", 293 "Timeout during download for type `%s', shutting down with error\n",
274 type); 294 type);
275 ok = 1; 295 ok = 1;
276 GNUNET_SCHEDULER_shutdown (); 296 cleanup ();
277 return; 297 return;
278 } 298 }
279 del = GNUNET_TIME_absolute_get_duration (start_time); 299 del = GNUNET_TIME_absolute_get_duration (start_time);
@@ -301,19 +321,22 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
301 321
302 322
303static void 323static void
304do_downloads (void *cls, const struct GNUNET_FS_Uri *u2) 324do_downloads (void *cls, const struct GNUNET_FS_Uri *u2,
325 const char *fn)
305{ 326{
306 int anonymity; 327 int anonymity;
307 unsigned int i; 328 unsigned int i;
308 329
309 if (NULL == u2) 330 if (NULL == u2)
310 { 331 {
311 GNUNET_SCHEDULER_shutdown (); 332 cleanup ();
312 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 333 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
313 "Timeout during upload attempt, shutting down with error\n"); 334 "Timeout during upload attempt, shutting down with error\n");
314 ok = 1; 335 ok = 1;
315 return; 336 return;
316 } 337 }
338 if (NULL != fn)
339 fn2 = GNUNET_strdup (fn);
317 uri2 = GNUNET_FS_uri_dup (u2); 340 uri2 = GNUNET_FS_uri_dup (u2);
318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", 341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
319 (unsigned long long) FILESIZE); 342 (unsigned long long) FILESIZE);
@@ -340,19 +363,22 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
340 363
341static void 364static void
342do_publish2 (void *cls, 365do_publish2 (void *cls,
343 const struct GNUNET_FS_Uri *u1) 366 const struct GNUNET_FS_Uri *u1,
367 const char *fn)
344{ 368{
345 int do_index; 369 int do_index;
346 int anonymity; 370 int anonymity;
347 371
348 if (NULL == u1) 372 if (NULL == u1)
349 { 373 {
350 GNUNET_SCHEDULER_shutdown (); 374 cleanup ();
351 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 375 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
352 "Timeout during upload attempt, shutting down with error\n"); 376 "Timeout during upload attempt, shutting down with error\n");
353 ok = 1; 377 ok = 1;
354 return; 378 return;
355 } 379 }
380 if (NULL != fn)
381 fn1 = GNUNET_strdup (fn);
356 uri1 = GNUNET_FS_uri_dup (u1); 382 uri1 = GNUNET_FS_uri_dup (u1);
357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", 383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
358 (unsigned long long) FILESIZE); 384 (unsigned long long) FILESIZE);
@@ -383,7 +409,7 @@ do_publish1 (void *cls,
383 GNUNET_TESTBED_operation_done (op); 409 GNUNET_TESTBED_operation_done (op);
384 if (NULL != emsg) 410 if (NULL != emsg)
385 { 411 {
386 GNUNET_SCHEDULER_shutdown (); 412 cleanup ();
387 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", emsg); 413 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", emsg);
388 ok = 1; 414 ok = 1;
389 return; 415 return;
diff --git a/src/fs/test_fs_test_lib.c b/src/fs/test_fs_test_lib.c
index 70e5977a6..2fe5a8140 100644
--- a/src/fs/test_fs_test_lib.c
+++ b/src/fs/test_fs_test_lib.c
@@ -50,6 +50,8 @@ static int ret;
50static void 50static void
51do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 51do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
52{ 52{
53 char *fn = cls;
54
53 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) 55 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
54 { 56 {
55 GNUNET_break (0); 57 GNUNET_break (0);
@@ -60,12 +62,18 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
60 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", 62 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
61 (unsigned long long) FILESIZE); 63 (unsigned long long) FILESIZE);
62 } 64 }
65 if (NULL != fn)
66 {
67 GNUNET_DISK_directory_remove (fn);
68 GNUNET_free (fn);
69 }
63 GNUNET_SCHEDULER_shutdown (); 70 GNUNET_SCHEDULER_shutdown ();
64} 71}
65 72
66 73
67static void 74static void
68do_download (void *cls, const struct GNUNET_FS_Uri *uri) 75do_download (void *cls, const struct GNUNET_FS_Uri *uri,
76 const char *fn)
69{ 77{
70 if (NULL == uri) 78 if (NULL == uri)
71 { 79 {
@@ -77,7 +85,7 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", 85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
78 (unsigned long long) FILESIZE); 86 (unsigned long long) FILESIZE);
79 GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop, 87 GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
80 NULL); 88 (NULL == fn) ? NULL : GNUNET_strdup (fn));
81} 89}
82 90
83 91
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index 7ffa94a98..2bc53540c 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -55,6 +55,14 @@ static struct GNUNET_TIME_Absolute start_time;
55static struct GNUNET_TESTBED_Operation *op; 55static struct GNUNET_TESTBED_Operation *op;
56 56
57 57
58struct DownloadContext
59{
60 char *fn;
61
62 struct GNUNET_FS_Uri *uri;
63};
64
65
58static void 66static void
59do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 67do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
60{ 68{
@@ -88,10 +96,17 @@ static void
88do_download (void *cls, 96do_download (void *cls,
89 const char *emsg) 97 const char *emsg)
90{ 98{
91 struct GNUNET_FS_Uri *uri = cls; 99 struct DownloadContext *dc = cls;
100 struct GNUNET_FS_Uri *uri = dc->uri;
92 101
93 GNUNET_TESTBED_operation_done (op); 102 GNUNET_TESTBED_operation_done (op);
94 op = NULL; 103 op = NULL;
104 if (NULL != dc->fn)
105 {
106 GNUNET_DISK_directory_remove (dc->fn);
107 GNUNET_free (dc->fn);
108 }
109 GNUNET_free (dc);
95 if (NULL != emsg) 110 if (NULL != emsg)
96 { 111 {
97 GNUNET_SCHEDULER_shutdown (); 112 GNUNET_SCHEDULER_shutdown ();
@@ -113,18 +128,19 @@ do_download (void *cls,
113static void 128static void
114stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 129stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
115{ 130{
116 struct GNUNET_FS_Uri *uri = cls; 131 struct DownloadContext *dc = cls;
117 132
118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n"); 133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n");
119 op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, uri); 134 op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, dc);
120 GNUNET_assert (NULL != op); 135 GNUNET_assert (NULL != op);
121} 136}
122 137
123 138
124static void 139static void
125do_wait (void *cls, const struct GNUNET_FS_Uri *uri) 140do_wait (void *cls, const struct GNUNET_FS_Uri *uri,
141 const char *fn)
126{ 142{
127 struct GNUNET_FS_Uri *d; 143 struct DownloadContext *dc;
128 144
129 if (NULL == uri) 145 if (NULL == uri)
130 { 146 {
@@ -135,8 +151,11 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri)
135 return; 151 return;
136 } 152 }
137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); 153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n");
138 d = GNUNET_FS_uri_dup (uri); 154 dc = GNUNET_malloc (sizeof (struct DownloadContext));
139 (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, d); 155 dc->uri = GNUNET_FS_uri_dup (uri);
156 if (NULL != fn)
157 dc->fn = GNUNET_strdup (fn);
158 (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, dc);
140} 159}
141 160
142 161
diff --git a/src/fs/test_gnunet_service_fs_p2p.c b/src/fs/test_gnunet_service_fs_p2p.c
index 889337ff4..d293bd66d 100644
--- a/src/fs/test_gnunet_service_fs_p2p.c
+++ b/src/fs/test_gnunet_service_fs_p2p.c
@@ -56,6 +56,7 @@ static struct GNUNET_TIME_Absolute start_time;
56static void 56static void
57do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 57do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
58{ 58{
59 char *fn = cls;
59 struct GNUNET_TIME_Relative del; 60 struct GNUNET_TIME_Relative del;
60 char *fancy; 61 char *fancy;
61 62
@@ -79,11 +80,17 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
79 "Timeout during download, shutting down with error\n"); 80 "Timeout during download, shutting down with error\n");
80 ok = 1; 81 ok = 1;
81 } 82 }
83 if (NULL != fn)
84 {
85 GNUNET_DISK_directory_remove (fn);
86 GNUNET_free (fn);
87 }
82} 88}
83 89
84 90
85static void 91static void
86do_download (void *cls, const struct GNUNET_FS_Uri *uri) 92do_download (void *cls, const struct GNUNET_FS_Uri *uri,
93 const char *fn)
87{ 94{
88 if (NULL == uri) 95 if (NULL == uri)
89 { 96 {
@@ -99,7 +106,9 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri)
99 GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 106 GNUNET_FS_TEST_download (daemons[0], TIMEOUT,
100 anonymity_level, SEED, uri, 107 anonymity_level, SEED, uri,
101 VERBOSE, &do_stop, 108 VERBOSE, &do_stop,
102 NULL); 109 (NULL == fn)
110 ? NULL
111 : GNUNET_strdup (fn));
103} 112}
104 113
105 114