diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/test_fs_search_persistence.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/test_fs_search_persistence.c')
-rw-r--r-- | src/fs/test_fs_search_persistence.c | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c index eceb4d1d5..5c5a6f140 100644 --- a/src/fs/test_fs_search_persistence.c +++ b/src/fs/test_fs_search_persistence.c | |||
@@ -94,10 +94,7 @@ static void | |||
94 | restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 94 | restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
95 | { | 95 | { |
96 | GNUNET_FS_stop (fs); | 96 | GNUNET_FS_stop (fs); |
97 | fs = GNUNET_FS_start (cfg, | 97 | fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, |
98 | "test-fs-search-persistence", | ||
99 | &progress_cb, | ||
100 | NULL, | ||
101 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); | 98 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); |
102 | } | 99 | } |
103 | 100 | ||
@@ -143,15 +140,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
143 | (unsigned long long) event->value.publish.completed, | 140 | (unsigned long long) event->value.publish.completed, |
144 | (unsigned long long) event->value.publish.size, | 141 | (unsigned long long) event->value.publish.size, |
145 | event->value.publish.specifics.progress.depth, | 142 | event->value.publish.specifics.progress.depth, |
146 | (unsigned long long) event->value.publish.specifics. | 143 | (unsigned long long) event->value.publish.specifics.progress. |
147 | progress.offset); | 144 | offset); |
148 | #endif | 145 | #endif |
149 | break; | 146 | break; |
150 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 147 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
151 | kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); | 148 | kuri = GNUNET_FS_uri_ksk_create_from_args (1, keywords); |
152 | start = GNUNET_TIME_absolute_get (); | 149 | start = GNUNET_TIME_absolute_get (); |
153 | GNUNET_FS_search_start (fs, | 150 | GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, |
154 | kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE, "search"); | 151 | "search"); |
155 | GNUNET_FS_uri_destroy (kuri); | 152 | GNUNET_FS_uri_destroy (kuri); |
156 | GNUNET_assert (search != NULL); | 153 | GNUNET_assert (search != NULL); |
157 | break; | 154 | break; |
@@ -169,25 +166,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
169 | #if VERBOSE | 166 | #if VERBOSE |
170 | printf ("Search complete.\n"); | 167 | printf ("Search complete.\n"); |
171 | #endif | 168 | #endif |
172 | GNUNET_SCHEDULER_add_continuation (&abort_search_task, | 169 | GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, |
173 | NULL, | ||
174 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 170 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
175 | break; | 171 | break; |
176 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 172 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
177 | fprintf (stderr, | 173 | fprintf (stderr, "Error publishing file: %s\n", |
178 | "Error publishing file: %s\n", | ||
179 | event->value.publish.specifics.error.message); | 174 | event->value.publish.specifics.error.message); |
180 | GNUNET_break (0); | 175 | GNUNET_break (0); |
181 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | 176 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, |
182 | NULL, | ||
183 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 177 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
184 | break; | 178 | break; |
185 | case GNUNET_FS_STATUS_SEARCH_ERROR: | 179 | case GNUNET_FS_STATUS_SEARCH_ERROR: |
186 | fprintf (stderr, | 180 | fprintf (stderr, "Error searching file: %s\n", |
187 | "Error searching file: %s\n", | ||
188 | event->value.search.specifics.error.message); | 181 | event->value.search.specifics.error.message); |
189 | GNUNET_SCHEDULER_add_continuation (&abort_search_task, | 182 | GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL, |
190 | NULL, | ||
191 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 183 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
192 | break; | 184 | break; |
193 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: | 185 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: |
@@ -226,8 +218,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
226 | break; | 218 | break; |
227 | case GNUNET_FS_STATUS_SEARCH_STOPPED: | 219 | case GNUNET_FS_STATUS_SEARCH_STOPPED: |
228 | GNUNET_assert (search == event->value.search.sc); | 220 | GNUNET_assert (search == event->value.search.sc); |
229 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, | 221 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL, |
230 | NULL, | ||
231 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 222 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
232 | search = NULL; | 223 | search = NULL; |
233 | break; | 224 | break; |
@@ -244,12 +235,13 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
244 | { | 235 | { |
245 | p->cfg = GNUNET_CONFIGURATION_create (); | 236 | p->cfg = GNUNET_CONFIGURATION_create (); |
246 | #if START_ARM | 237 | #if START_ARM |
247 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 238 | p->arm_proc = |
248 | "gnunet-service-arm", | 239 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
240 | "gnunet-service-arm", | ||
249 | #if VERBOSE | 241 | #if VERBOSE |
250 | "-L", "DEBUG", | 242 | "-L", "DEBUG", |
251 | #endif | 243 | #endif |
252 | "-c", cfgname, NULL); | 244 | "-c", cfgname, NULL); |
253 | #endif | 245 | #endif |
254 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 246 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
255 | } | 247 | } |
@@ -265,8 +257,7 @@ stop_arm (struct PeerContext *p) | |||
265 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 257 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
266 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | 258 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
267 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 259 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); |
268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", |
269 | "ARM process %u stopped\n", | ||
270 | GNUNET_OS_process_get_pid (p->arm_proc)); | 261 | GNUNET_OS_process_get_pid (p->arm_proc)); |
271 | GNUNET_OS_process_close (p->arm_proc); | 262 | GNUNET_OS_process_close (p->arm_proc); |
272 | p->arm_proc = NULL; | 263 | p->arm_proc = NULL; |
@@ -277,9 +268,8 @@ stop_arm (struct PeerContext *p) | |||
277 | 268 | ||
278 | 269 | ||
279 | static void | 270 | static void |
280 | run (void *cls, | 271 | run (void *cls, char *const *args, const char *cfgfile, |
281 | char *const *args, | 272 | const struct GNUNET_CONFIGURATION_Handle *c) |
282 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
283 | { | 273 | { |
284 | const char *keywords[] = { | 274 | const char *keywords[] = { |
285 | "down_foo", | 275 | "down_foo", |
@@ -294,10 +284,7 @@ run (void *cls, | |||
294 | 284 | ||
295 | cfg = c; | 285 | cfg = c; |
296 | setup_peer (&p1, "test_fs_search_data.conf"); | 286 | setup_peer (&p1, "test_fs_search_data.conf"); |
297 | fs = GNUNET_FS_start (cfg, | 287 | fs = GNUNET_FS_start (cfg, "test-fs-search-persistence", &progress_cb, NULL, |
298 | "test-fs-search-persistence", | ||
299 | &progress_cb, | ||
300 | NULL, | ||
301 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); | 288 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); |
302 | GNUNET_assert (NULL != fs); | 289 | GNUNET_assert (NULL != fs); |
303 | buf = GNUNET_malloc (FILESIZE); | 290 | buf = GNUNET_malloc (FILESIZE); |
@@ -309,19 +296,16 @@ run (void *cls, | |||
309 | bo.anonymity_level = 1; | 296 | bo.anonymity_level = 1; |
310 | bo.replication_level = 0; | 297 | bo.replication_level = 0; |
311 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); | 298 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); |
312 | fi = GNUNET_FS_file_information_create_from_data (fs, | 299 | fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", |
313 | "publish-context", | 300 | FILESIZE, buf, kuri, meta, |
314 | FILESIZE, | 301 | GNUNET_NO, &bo); |
315 | buf, | ||
316 | kuri, meta, GNUNET_NO, &bo); | ||
317 | GNUNET_FS_uri_destroy (kuri); | 302 | GNUNET_FS_uri_destroy (kuri); |
318 | GNUNET_CONTAINER_meta_data_destroy (meta); | 303 | GNUNET_CONTAINER_meta_data_destroy (meta); |
319 | GNUNET_assert (NULL != fi); | 304 | GNUNET_assert (NULL != fi); |
320 | start = GNUNET_TIME_absolute_get (); | 305 | start = GNUNET_TIME_absolute_get (); |
321 | publish = GNUNET_FS_publish_start (fs, | 306 | publish = |
322 | fi, | 307 | GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, |
323 | NULL, NULL, NULL, | 308 | GNUNET_FS_PUBLISH_OPTION_NONE); |
324 | GNUNET_FS_PUBLISH_OPTION_NONE); | ||
325 | GNUNET_assert (publish != NULL); | 309 | GNUNET_assert (publish != NULL); |
326 | } | 310 | } |
327 | 311 | ||
@@ -350,9 +334,9 @@ main (int argc, char *argv[]) | |||
350 | "WARNING", | 334 | "WARNING", |
351 | #endif | 335 | #endif |
352 | NULL); | 336 | NULL); |
353 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 337 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, |
354 | argvx, "test-fs-search-persistence", | 338 | "test-fs-search-persistence", "nohelp", options, &run, |
355 | "nohelp", options, &run, NULL); | 339 | NULL); |
356 | stop_arm (&p1); | 340 | stop_arm (&p1); |
357 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); | 341 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); |
358 | return 0; | 342 | return 0; |