aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_fs_unindex_persistence.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/fs/test_fs_unindex_persistence.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs/test_fs_unindex_persistence.c')
-rw-r--r--src/fs/test_fs_unindex_persistence.c81
1 files changed, 32 insertions, 49 deletions
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index 191dec57d..4fcd1445f 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -102,10 +102,7 @@ static void
102restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 102restart_fs_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
103{ 103{
104 GNUNET_FS_stop (fs); 104 GNUNET_FS_stop (fs);
105 fs = GNUNET_FS_start (cfg, 105 fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL,
106 "test-fs-unindex-persistence",
107 &progress_cb,
108 NULL,
109 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 106 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
110} 107}
111 108
@@ -144,16 +141,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
144 (unsigned long long) event->value.publish.completed, 141 (unsigned long long) event->value.publish.completed,
145 (unsigned long long) event->value.publish.size, 142 (unsigned long long) event->value.publish.size,
146 event->value.publish.specifics.progress.depth, 143 event->value.publish.specifics.progress.depth,
147 (unsigned long long) event->value.publish.specifics. 144 (unsigned long long) event->value.publish.specifics.progress.
148 progress.offset); 145 offset);
149#endif 146#endif
150 break; 147 break;
151 case GNUNET_FS_STATUS_PUBLISH_COMPLETED: 148 case GNUNET_FS_STATUS_PUBLISH_COMPLETED:
152 printf ("Publishing complete, %llu kbps.\n", 149 printf ("Publishing complete, %llu kbps.\n",
153 (unsigned long long) (FILESIZE * 1000 / 150 (unsigned long long) (FILESIZE * 1000 /
154 (1 + 151 (1 +
155 GNUNET_TIME_absolute_get_duration 152 GNUNET_TIME_absolute_get_duration (start).
156 (start).rel_value) / 1024)); 153 rel_value) / 1024));
157 start = GNUNET_TIME_absolute_get (); 154 start = GNUNET_TIME_absolute_get ();
158 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex"); 155 unindex = GNUNET_FS_unindex_start (fs, fn, "unindex");
159 GNUNET_assert (unindex != NULL); 156 GNUNET_assert (unindex != NULL);
@@ -162,8 +159,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
162 printf ("Unindex complete, %llu kbps.\n", 159 printf ("Unindex complete, %llu kbps.\n",
163 (unsigned long long) (FILESIZE * 1000 / 160 (unsigned long long) (FILESIZE * 1000 /
164 (1 + 161 (1 +
165 GNUNET_TIME_absolute_get_duration 162 GNUNET_TIME_absolute_get_duration (start).
166 (start).rel_value) / 1024)); 163 rel_value) / 1024));
167 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL, 164 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
168 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 165 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
169 break; 166 break;
@@ -175,8 +172,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
175 (unsigned long long) event->value.unindex.completed, 172 (unsigned long long) event->value.unindex.completed,
176 (unsigned long long) event->value.unindex.size, 173 (unsigned long long) event->value.unindex.size,
177 event->value.unindex.specifics.progress.depth, 174 event->value.unindex.specifics.progress.depth,
178 (unsigned long long) event->value.unindex.specifics. 175 (unsigned long long) event->value.unindex.specifics.progress.
179 progress.offset); 176 offset);
180#endif 177#endif
181 break; 178 break;
182 case GNUNET_FS_STATUS_PUBLISH_SUSPEND: 179 case GNUNET_FS_STATUS_PUBLISH_SUSPEND:
@@ -199,20 +196,16 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
199 unindex = event->value.unindex.uc; 196 unindex = event->value.unindex.uc;
200 return "unindex"; 197 return "unindex";
201 case GNUNET_FS_STATUS_PUBLISH_ERROR: 198 case GNUNET_FS_STATUS_PUBLISH_ERROR:
202 fprintf (stderr, 199 fprintf (stderr, "Error publishing file: %s\n",
203 "Error publishing file: %s\n",
204 event->value.publish.specifics.error.message); 200 event->value.publish.specifics.error.message);
205 GNUNET_break (0); 201 GNUNET_break (0);
206 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 202 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
207 NULL,
208 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 203 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
209 break; 204 break;
210 case GNUNET_FS_STATUS_UNINDEX_ERROR: 205 case GNUNET_FS_STATUS_UNINDEX_ERROR:
211 fprintf (stderr, 206 fprintf (stderr, "Error unindexing file: %s\n",
212 "Error unindexing file: %s\n",
213 event->value.unindex.specifics.error.message); 207 event->value.unindex.specifics.error.message);
214 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, 208 GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
215 NULL,
216 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 209 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
217 break; 210 break;
218 case GNUNET_FS_STATUS_PUBLISH_START: 211 case GNUNET_FS_STATUS_PUBLISH_START:
@@ -239,8 +232,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
239 break; 232 break;
240 case GNUNET_FS_STATUS_UNINDEX_STOPPED: 233 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
241 GNUNET_assert (unindex == event->value.unindex.uc); 234 GNUNET_assert (unindex == event->value.unindex.uc);
242 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, 235 GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
243 NULL,
244 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 236 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
245 break; 237 break;
246 default: 238 default:
@@ -256,12 +248,13 @@ setup_peer (struct PeerContext *p, const char *cfgname)
256{ 248{
257 p->cfg = GNUNET_CONFIGURATION_create (); 249 p->cfg = GNUNET_CONFIGURATION_create ();
258#if START_ARM 250#if START_ARM
259 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 251 p->arm_proc =
260 "gnunet-service-arm", 252 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
253 "gnunet-service-arm",
261#if VERBOSE 254#if VERBOSE
262 "-L", "DEBUG", 255 "-L", "DEBUG",
263#endif 256#endif
264 "-c", cfgname, NULL); 257 "-c", cfgname, NULL);
265#endif 258#endif
266 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 259 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
267} 260}
@@ -277,8 +270,7 @@ stop_arm (struct PeerContext *p)
277 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
278 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) 271 if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
279 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
280 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n",
281 "ARM process %u stopped\n",
282 GNUNET_OS_process_get_pid (p->arm_proc)); 274 GNUNET_OS_process_get_pid (p->arm_proc));
283 GNUNET_OS_process_close (p->arm_proc); 275 GNUNET_OS_process_close (p->arm_proc);
284 p->arm_proc = NULL; 276 p->arm_proc = NULL;
@@ -289,9 +281,8 @@ stop_arm (struct PeerContext *p)
289 281
290 282
291static void 283static void
292run (void *cls, 284run (void *cls, char *const *args, const char *cfgfile,
293 char *const *args, 285 const struct GNUNET_CONFIGURATION_Handle *c)
294 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
295{ 286{
296 const char *keywords[] = { 287 const char *keywords[] = {
297 "down_foo", 288 "down_foo",
@@ -307,19 +298,14 @@ run (void *cls,
307 cfg = c; 298 cfg = c;
308 setup_peer (&p1, "test_fs_unindex_data.conf"); 299 setup_peer (&p1, "test_fs_unindex_data.conf");
309 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); 300 fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst");
310 fs = GNUNET_FS_start (cfg, 301 fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL,
311 "test-fs-unindex-persistence",
312 &progress_cb,
313 NULL,
314 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); 302 GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END);
315 GNUNET_assert (NULL != fs); 303 GNUNET_assert (NULL != fs);
316 buf = GNUNET_malloc (FILESIZE); 304 buf = GNUNET_malloc (FILESIZE);
317 for (i = 0; i < FILESIZE; i++) 305 for (i = 0; i < FILESIZE; i++)
318 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); 306 buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256);
319 GNUNET_assert (FILESIZE == 307 GNUNET_assert (FILESIZE ==
320 GNUNET_DISK_fn_write (fn, 308 GNUNET_DISK_fn_write (fn, buf, FILESIZE,
321 buf,
322 FILESIZE,
323 GNUNET_DISK_PERM_USER_READ | 309 GNUNET_DISK_PERM_USER_READ |
324 GNUNET_DISK_PERM_USER_WRITE)); 310 GNUNET_DISK_PERM_USER_WRITE));
325 GNUNET_free (buf); 311 GNUNET_free (buf);
@@ -329,19 +315,16 @@ run (void *cls,
329 bo.anonymity_level = 1; 315 bo.anonymity_level = 1;
330 bo.replication_level = 0; 316 bo.replication_level = 0;
331 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); 317 bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME);
332 fi = GNUNET_FS_file_information_create_from_file (fs, 318 fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn,
333 "publish-context", 319 kuri, meta, GNUNET_YES,
334 fn, 320 &bo);
335 kuri,
336 meta, GNUNET_YES, &bo);
337 GNUNET_FS_uri_destroy (kuri); 321 GNUNET_FS_uri_destroy (kuri);
338 GNUNET_CONTAINER_meta_data_destroy (meta); 322 GNUNET_CONTAINER_meta_data_destroy (meta);
339 GNUNET_assert (NULL != fi); 323 GNUNET_assert (NULL != fi);
340 start = GNUNET_TIME_absolute_get (); 324 start = GNUNET_TIME_absolute_get ();
341 publish = GNUNET_FS_publish_start (fs, 325 publish =
342 fi, 326 GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL,
343 NULL, NULL, NULL, 327 GNUNET_FS_PUBLISH_OPTION_NONE);
344 GNUNET_FS_PUBLISH_OPTION_NONE);
345 GNUNET_assert (publish != NULL); 328 GNUNET_assert (publish != NULL);
346} 329}
347 330
@@ -369,8 +352,8 @@ main (int argc, char *argv[])
369 "WARNING", 352 "WARNING",
370#endif 353#endif
371 NULL); 354 NULL);
372 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 355 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
373 argvx, "test-fs-unindex", "nohelp", options, &run, NULL); 356 "test-fs-unindex", "nohelp", options, &run, NULL);
374 stop_arm (&p1); 357 stop_arm (&p1);
375 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); 358 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/");
376 if (NULL != fn) 359 if (NULL != fn)