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/perf_gnunet_service_fs_p2p.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/perf_gnunet_service_fs_p2p.c')
-rw-r--r-- | src/fs/perf_gnunet_service_fs_p2p.c | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 92441e901..0737ea949 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c | |||
@@ -115,15 +115,13 @@ static struct StatValues stats[] = { | |||
115 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 115 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
116 | */ | 116 | */ |
117 | static int | 117 | static int |
118 | print_stat (void *cls, | 118 | print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, |
119 | const char *subsystem, | 119 | int is_persistent) |
120 | const char *name, uint64_t value, int is_persistent) | ||
121 | { | 120 | { |
122 | struct StatMaster *sm = cls; | 121 | struct StatMaster *sm = cls; |
123 | 122 | ||
124 | fprintf (stderr, | 123 | fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, |
125 | "Peer %2u: %12s/%50s = %12llu\n", | 124 | name, (unsigned long long) value); |
126 | sm->daemon, subsystem, name, (unsigned long long) value); | ||
127 | return GNUNET_OK; | 125 | return GNUNET_OK; |
128 | } | 126 | } |
129 | 127 | ||
@@ -164,8 +162,8 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
164 | #else | 162 | #else |
165 | stats[sm->value].subsystem, stats[sm->value].name, | 163 | stats[sm->value].subsystem, stats[sm->value].name, |
166 | #endif | 164 | #endif |
167 | GNUNET_TIME_UNIT_FOREVER_REL, | 165 | GNUNET_TIME_UNIT_FOREVER_REL, &get_done, &print_stat, |
168 | &get_done, &print_stat, sm); | 166 | sm); |
169 | return; | 167 | return; |
170 | } | 168 | } |
171 | GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); | 169 | GNUNET_STATISTICS_destroy (sm->stat, GNUNET_NO); |
@@ -177,9 +175,10 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
177 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); | 175 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
178 | return; | 176 | return; |
179 | } | 177 | } |
180 | sm->stat = GNUNET_STATISTICS_create ("<driver>", | 178 | sm->stat = |
181 | GNUNET_FS_TEST_get_configuration | 179 | GNUNET_STATISTICS_create ("<driver>", |
182 | (daemons, sm->daemon)); | 180 | GNUNET_FS_TEST_get_configuration (daemons, |
181 | sm->daemon)); | ||
183 | GNUNET_SCHEDULER_add_now (&stat_run, sm); | 182 | GNUNET_SCHEDULER_add_now (&stat_run, sm); |
184 | } | 183 | } |
185 | 184 | ||
@@ -201,13 +200,14 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
201 | 1000LL / del.rel_value); | 200 | 1000LL / del.rel_value); |
202 | fprintf (stdout, "Download speed was %s/s\n", fancy); | 201 | fprintf (stdout, "Download speed was %s/s\n", fancy); |
203 | GNUNET_free (fancy); | 202 | GNUNET_free (fancy); |
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", |
205 | "Finished download, shutting down\n", | ||
206 | (unsigned long long) FILESIZE); | 204 | (unsigned long long) FILESIZE); |
207 | sm = GNUNET_malloc (sizeof (struct StatMaster)); | 205 | sm = GNUNET_malloc (sizeof (struct StatMaster)); |
208 | sm->stat = GNUNET_STATISTICS_create ("<driver>", | 206 | sm->stat = |
209 | GNUNET_FS_TEST_get_configuration | 207 | GNUNET_STATISTICS_create ("<driver>", |
210 | (daemons, sm->daemon)); | 208 | GNUNET_FS_TEST_get_configuration (daemons, |
209 | sm-> | ||
210 | daemon)); | ||
211 | GNUNET_SCHEDULER_add_now (&stat_run, sm); | 211 | GNUNET_SCHEDULER_add_now (&stat_run, sm); |
212 | } | 212 | } |
213 | else | 213 | else |
@@ -233,16 +233,15 @@ do_download (void *cls, const struct GNUNET_FS_Uri *uri) | |||
233 | ok = 1; | 233 | ok = 1; |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", |
237 | "Downloading %llu bytes\n", (unsigned long long) FILESIZE); | 237 | (unsigned long long) FILESIZE); |
238 | start_time = GNUNET_TIME_absolute_get (); | 238 | start_time = GNUNET_TIME_absolute_get (); |
239 | if (NULL != strstr (progname, "dht")) | 239 | if (NULL != strstr (progname, "dht")) |
240 | anonymity = 0; | 240 | anonymity = 0; |
241 | else | 241 | else |
242 | anonymity = 1; | 242 | anonymity = 1; |
243 | GNUNET_FS_TEST_download (daemons[0], | 243 | GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE, |
244 | TIMEOUT, | 244 | &do_report, NULL); |
245 | anonymity, SEED, uri, VERBOSE, &do_report, NULL); | ||
246 | } | 245 | } |
247 | 246 | ||
248 | 247 | ||
@@ -259,8 +258,8 @@ do_publish (void *cls, const char *emsg) | |||
259 | ok = 1; | 258 | ok = 1; |
260 | return; | 259 | return; |
261 | } | 260 | } |
262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
263 | "Publishing %llu bytes\n", (unsigned long long) FILESIZE); | 262 | (unsigned long long) FILESIZE); |
264 | if (NULL != strstr (progname, "index")) | 263 | if (NULL != strstr (progname, "index")) |
265 | do_index = GNUNET_YES; | 264 | do_index = GNUNET_YES; |
266 | else | 265 | else |
@@ -270,11 +269,9 @@ do_publish (void *cls, const char *emsg) | |||
270 | else | 269 | else |
271 | anonymity = 1; | 270 | anonymity = 1; |
272 | 271 | ||
273 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], | 272 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, |
274 | TIMEOUT, | 273 | do_index, FILESIZE, SEED, VERBOSE, &do_download, |
275 | anonymity, | 274 | NULL); |
276 | do_index, FILESIZE, SEED, | ||
277 | VERBOSE, &do_download, NULL); | ||
278 | } | 275 | } |
279 | 276 | ||
280 | 277 | ||
@@ -287,27 +284,22 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
288 | "Daemons started, will now try to connect them\n"); | 285 | "Daemons started, will now try to connect them\n"); |
289 | pg = GNUNET_FS_TEST_get_group (daemons); | 286 | pg = GNUNET_FS_TEST_get_group (daemons); |
290 | GNUNET_break ((NUM_DAEMONS - 1) * 2 | 287 | GNUNET_break ((NUM_DAEMONS - 1) * 2 == |
291 | == (GNUNET_TESTING_create_topology (pg, | 288 | (GNUNET_TESTING_create_topology |
292 | GNUNET_TESTING_TOPOLOGY_LINE, | 289 | (pg, GNUNET_TESTING_TOPOLOGY_LINE, |
293 | GNUNET_TESTING_TOPOLOGY_NONE, | 290 | GNUNET_TESTING_TOPOLOGY_NONE, NULL))); |
294 | NULL))); | 291 | GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, |
295 | GNUNET_TESTING_connect_topology (pg, | 292 | GNUNET_TESTING_TOPOLOGY_OPTION_NONE, 0.0, |
296 | GNUNET_TESTING_TOPOLOGY_LINE, | ||
297 | GNUNET_TESTING_TOPOLOGY_OPTION_NONE, | ||
298 | 0.0, | ||
299 | TIMEOUT, NUM_DAEMONS, &do_publish, NULL); | 293 | TIMEOUT, NUM_DAEMONS, &do_publish, NULL); |
300 | } | 294 | } |
301 | 295 | ||
302 | 296 | ||
303 | static void | 297 | static void |
304 | run (void *cls, | 298 | run (void *cls, char *const *args, const char *cfgfile, |
305 | char *const *args, | 299 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
306 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
307 | { | 300 | { |
308 | GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", | 301 | GNUNET_FS_TEST_daemons_start ("fs_test_lib_data.conf", TIMEOUT, NUM_DAEMONS, |
309 | TIMEOUT, | 302 | daemons, &do_connect, NULL); |
310 | NUM_DAEMONS, daemons, &do_connect, NULL); | ||
311 | } | 303 | } |
312 | 304 | ||
313 | 305 | ||
@@ -335,9 +327,9 @@ main (int argc, char *argv[]) | |||
335 | "WARNING", | 327 | "WARNING", |
336 | #endif | 328 | #endif |
337 | NULL); | 329 | NULL); |
338 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 330 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, |
339 | argvx, "perf-gnunet-service-fs-p2p-index", | 331 | "perf-gnunet-service-fs-p2p-index", "nohelp", options, |
340 | "nohelp", options, &run, NULL); | 332 | &run, NULL); |
341 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 333 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); |
342 | return ok; | 334 | return ok; |
343 | } | 335 | } |