aboutsummaryrefslogtreecommitdiff
path: root/src/fs/perf_gnunet_service_fs_p2p_trust.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/perf_gnunet_service_fs_p2p_trust.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/fs/perf_gnunet_service_fs_p2p_trust.c')
-rw-r--r--src/fs/perf_gnunet_service_fs_p2p_trust.c102
1 files changed, 44 insertions, 58 deletions
diff --git a/src/fs/perf_gnunet_service_fs_p2p_trust.c b/src/fs/perf_gnunet_service_fs_p2p_trust.c
index a78ff0571..5a8d4242a 100644
--- a/src/fs/perf_gnunet_service_fs_p2p_trust.c
+++ b/src/fs/perf_gnunet_service_fs_p2p_trust.c
@@ -148,15 +148,13 @@ static struct StatValues stats[] = {
148 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 148 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
149 */ 149 */
150static int 150static int
151print_stat (void *cls, 151print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
152 const char *subsystem, 152 int is_persistent)
153 const char *name, uint64_t value, int is_persistent)
154{ 153{
155 struct StatMaster *sm = cls; 154 struct StatMaster *sm = cls;
156 155
157 fprintf (stderr, 156 fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
158 "Peer %2u: %12s/%50s = %12llu\n", 157 name, (unsigned long long) value);
159 sm->daemon, subsystem, name, (unsigned long long) value);
160 return GNUNET_OK; 158 return GNUNET_OK;
161} 159}
162 160
@@ -197,8 +195,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
197#else 195#else
198 stats[sm->value].subsystem, stats[sm->value].name, 196 stats[sm->value].subsystem, stats[sm->value].name,
199#endif 197#endif
200 GNUNET_TIME_UNIT_FOREVER_REL, 198 GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat,
201 &get_done, &print_stat, sm); 199 sm);
202 return; 200 return;
203 } 201 }
204 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); 202 GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO);
@@ -210,9 +208,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
210 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 208 GNUNET_SCHEDULER_add_now (&do_stop, NULL);
211 return; 209 return;
212 } 210 }
213 sm->stat = GNUNET_STATISTICS_create ("<driver>", 211 sm->stat =
214 GNUNET_FS_TEST_get_configuration 212 GNUNET_STATISTICS_create ("<driver>",
215 (daemons, sm->daemon)); 213 GNUNET_FS_TEST_get_configuration (daemons,
214 sm->daemon));
216 GNUNET_SCHEDULER_add_now (&stat_run, sm); 215 GNUNET_SCHEDULER_add_now (&stat_run, sm);
217} 216}
218 217
@@ -242,9 +241,11 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
242 "Finished all downloads, shutting down\n", 241 "Finished all downloads, shutting down\n",
243 (unsigned long long) FILESIZE); 242 (unsigned long long) FILESIZE);
244 sm = GNUNET_malloc (sizeof (struct StatMaster)); 243 sm = GNUNET_malloc (sizeof (struct StatMaster));
245 sm->stat = GNUNET_STATISTICS_create ("<driver>", 244 sm->stat =
246 GNUNET_FS_TEST_get_configuration 245 GNUNET_STATISTICS_create ("<driver>",
247 (daemons, sm->daemon)); 246 GNUNET_FS_TEST_get_configuration (daemons,
247 sm->
248 daemon));
248 GNUNET_SCHEDULER_add_now (&stat_run, sm); 249 GNUNET_SCHEDULER_add_now (&stat_run, sm);
249 } 250 }
250 else 251 else
@@ -273,8 +274,8 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
273 return; 274 return;
274 } 275 }
275 uri2 = GNUNET_FS_uri_dup (u2); 276 uri2 = GNUNET_FS_uri_dup (u2);
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
277 "Downloading %llu bytes\n", (unsigned long long) FILESIZE); 278 (unsigned long long) FILESIZE);
278 start_time = GNUNET_TIME_absolute_get (); 279 start_time = GNUNET_TIME_absolute_get ();
279 if (NULL != strstr (progname, "dht")) 280 if (NULL != strstr (progname, "dht"))
280 anonymity = 0; 281 anonymity = 0;
@@ -284,21 +285,15 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
284 * these peers do participate in sharing, they just 285 * these peers do participate in sharing, they just
285 * don't have to offer anything *initially*. */ 286 * don't have to offer anything *initially*. */
286 for (i = 0; i < NUM_DAEMONS - 2; i++) 287 for (i = 0; i < NUM_DAEMONS - 2; i++)
287 GNUNET_FS_TEST_download (daemons[i], 288 GNUNET_FS_TEST_download (daemons[i], TIMEOUT, anonymity,
288 TIMEOUT,
289 anonymity,
290 0 == (i % 2) ? SEED1 : SEED2, 289 0 == (i % 2) ? SEED1 : SEED2,
291 0 == (i % 2) ? uri1 : uri2, 290 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report,
292 VERBOSE, &do_report, "leach"); 291 "leach");
293 /* mutual downloads of (primary) sharing peers */ 292 /* mutual downloads of (primary) sharing peers */
294 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], 293 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1,
295 TIMEOUT, 294 uri1, VERBOSE, &do_report, "seeder 2");
296 anonymity, SEED1, uri1, 295 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2,
297 VERBOSE, &do_report, "seeder 2"); 296 uri2, VERBOSE, &do_report, "seeder 1");
298 GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1],
299 TIMEOUT,
300 anonymity, SEED2, uri2,
301 VERBOSE, &do_report, "seeder 1");
302} 297}
303 298
304 299
@@ -317,8 +312,8 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1)
317 return; 312 return;
318 } 313 }
319 uri1 = GNUNET_FS_uri_dup (u1); 314 uri1 = GNUNET_FS_uri_dup (u1);
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
321 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 316 (unsigned long long) FILESIZE);
322 if (NULL != strstr (progname, "index")) 317 if (NULL != strstr (progname, "index"))
323 do_index = GNUNET_YES; 318 do_index = GNUNET_YES;
324 else 319 else
@@ -328,11 +323,9 @@ do_publish2 (void *cls, const struct GNUNET_FS_Uri *u1)
328 else 323 else
329 anonymity = 1; 324 anonymity = 1;
330 325
331 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], 326 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity,
332 TIMEOUT, 327 do_index, FILESIZE, SEED2, VERBOSE, &do_downloads,
333 anonymity, 328 NULL);
334 do_index, FILESIZE, SEED2,
335 VERBOSE, &do_downloads, NULL);
336} 329}
337 330
338static void 331static void
@@ -348,8 +341,8 @@ do_publish1 (void *cls, const char *emsg)
348 ok = 1; 341 ok = 1;
349 return; 342 return;
350 } 343 }
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
352 "Publishing %llu bytes\n", (unsigned long long) FILESIZE); 345 (unsigned long long) FILESIZE);
353 if (NULL != strstr (progname, "index")) 346 if (NULL != strstr (progname, "index"))
354 do_index = GNUNET_YES; 347 do_index = GNUNET_YES;
355 else 348 else
@@ -359,11 +352,9 @@ do_publish1 (void *cls, const char *emsg)
359 else 352 else
360 anonymity = 1; 353 anonymity = 1;
361 354
362 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], 355 GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity,
363 TIMEOUT, 356 do_index, FILESIZE, SEED1, VERBOSE, &do_publish2,
364 anonymity, 357 NULL);
365 do_index, FILESIZE, SEED1,
366 VERBOSE, &do_publish2, NULL);
367} 358}
368 359
369 360
@@ -376,25 +367,20 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
377 "Daemons started, will now try to connect them\n"); 368 "Daemons started, will now try to connect them\n");
378 pg = GNUNET_FS_TEST_get_group (daemons); 369 pg = GNUNET_FS_TEST_get_group (daemons);
379 GNUNET_TESTING_create_topology (pg, 370 GNUNET_TESTING_create_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE,
380 GNUNET_TESTING_TOPOLOGY_CLIQUE,
381 GNUNET_TESTING_TOPOLOGY_NONE, NULL); 371 GNUNET_TESTING_TOPOLOGY_NONE, NULL);
382 GNUNET_TESTING_connect_topology (pg, 372 GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE,
383 GNUNET_TESTING_TOPOLOGY_CLIQUE, 373 GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0,
384 GNUNET_TESTING_TOPOLOGY_OPTION_NONE,
385 0.0,
386 TIMEOUT, NUM_DAEMONS, &do_publish1, NULL); 374 TIMEOUT, NUM_DAEMONS, &do_publish1, NULL);
387} 375}
388 376
389 377
390static void 378static void
391run (void *cls, 379run (void *cls, char *const *args, const char *cfgfile,
392 char *const *args, 380 const struct GNUNET_CONFIGURATION_Handle *cfg)
393 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
394{ 381{
395 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", 382 GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS,
396 TIMEOUT, 383 daemons, &do_connect, NULL);
397 NUM_DAEMONS, daemons, &do_connect, NULL);
398} 384}
399 385
400 386
@@ -422,9 +408,9 @@ main (int argc, char *argv[])
422 "WARNING", 408 "WARNING",
423#endif 409#endif
424 NULL); 410 NULL);
425 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, 411 GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx,
426 argvx, "perf-gnunet-service-fs-p2p-trust", 412 "perf-gnunet-service-fs-p2p-trust", "nohelp", options,
427 "nohelp", options, &run, NULL); 413 &run, NULL);
428 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); 414 GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/");
429 return ok; 415 return ok;
430} 416}