diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/fs/perf_gnunet_service_fs_p2p_respect.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/perf_gnunet_service_fs_p2p_respect.c')
-rw-r--r-- | src/fs/perf_gnunet_service_fs_p2p_respect.c | 378 |
1 files changed, 188 insertions, 190 deletions
diff --git a/src/fs/perf_gnunet_service_fs_p2p_respect.c b/src/fs/perf_gnunet_service_fs_p2p_respect.c index 9b14b9eb6..91ec9c66d 100644 --- a/src/fs/perf_gnunet_service_fs_p2p_respect.c +++ b/src/fs/perf_gnunet_service_fs_p2p_respect.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file fs/perf_gnunet_service_fs_p2p_respect.c | 22 | * @file fs/perf_gnunet_service_fs_p2p_respect.c |
@@ -57,7 +57,7 @@ | |||
57 | /** | 57 | /** |
58 | * How long until we give up on transmitting the message? | 58 | * How long until we give up on transmitting the message? |
59 | */ | 59 | */ |
60 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) | 60 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 30) |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Number of daemons in clique, must be at least 3 (!). | 63 | * Number of daemons in clique, must be at least 3 (!). |
@@ -93,16 +93,14 @@ static char *fn2; | |||
93 | /** | 93 | /** |
94 | * Master context for 'stat_run'. | 94 | * Master context for 'stat_run'. |
95 | */ | 95 | */ |
96 | struct StatMaster | 96 | struct StatMaster { |
97 | { | ||
98 | struct GNUNET_STATISTICS_Handle *stat; | 97 | struct GNUNET_STATISTICS_Handle *stat; |
99 | struct GNUNET_TESTBED_Operation *op; | 98 | struct GNUNET_TESTBED_Operation *op; |
100 | unsigned int daemon; | 99 | unsigned int daemon; |
101 | unsigned int value; | 100 | unsigned int value; |
102 | }; | 101 | }; |
103 | 102 | ||
104 | struct StatValues | 103 | struct StatValues { |
105 | { | ||
106 | const char *subsystem; | 104 | const char *subsystem; |
107 | const char *name; | 105 | const char *name; |
108 | }; | 106 | }; |
@@ -111,44 +109,44 @@ struct StatValues | |||
111 | * Statistics we print out. | 109 | * Statistics we print out. |
112 | */ | 110 | */ |
113 | static struct StatValues stats[] = { | 111 | static struct StatValues stats[] = { |
114 | {"fs", "# artificial delays introduced (ms)"}, | 112 | { "fs", "# artificial delays introduced (ms)" }, |
115 | {"fs", "# queries forwarded"}, | 113 | { "fs", "# queries forwarded" }, |
116 | {"fs", "# replies received and matched"}, | 114 | { "fs", "# replies received and matched" }, |
117 | {"fs", "# results found locally"}, | 115 | { "fs", "# results found locally" }, |
118 | {"fs", "# requests forwarded due to high load"}, | 116 | { "fs", "# requests forwarded due to high load" }, |
119 | {"fs", "# requests done for free (low load)"}, | 117 | { "fs", "# requests done for free (low load)" }, |
120 | {"fs", "# requests dropped, priority insufficient"}, | 118 | { "fs", "# requests dropped, priority insufficient" }, |
121 | {"fs", "# requests done for a price (normal load)"}, | 119 | { "fs", "# requests done for a price (normal load)" }, |
122 | {"fs", "# requests dropped by datastore (queue length limit)"}, | 120 | { "fs", "# requests dropped by datastore (queue length limit)" }, |
123 | {"fs", "# P2P searches received"}, | 121 | { "fs", "# P2P searches received" }, |
124 | {"fs", "# P2P searches discarded (queue length bound)"}, | 122 | { "fs", "# P2P searches discarded (queue length bound)" }, |
125 | {"fs", "# replies received for local clients"}, | 123 | { "fs", "# replies received for local clients" }, |
126 | {"fs", "# queries retransmitted to same target"}, | 124 | { "fs", "# queries retransmitted to same target" }, |
127 | {"core", "# bytes decrypted"}, | 125 | { "core", "# bytes decrypted" }, |
128 | {"core", "# bytes encrypted"}, | 126 | { "core", "# bytes encrypted" }, |
129 | {"core", "# discarded CORE_SEND requests"}, | 127 | { "core", "# discarded CORE_SEND requests" }, |
130 | {"core", "# discarded lower priority CORE_SEND requests"}, | 128 | { "core", "# discarded lower priority CORE_SEND requests" }, |
131 | {"transport", "# bytes received via TCP"}, | 129 | { "transport", "# bytes received via TCP" }, |
132 | {"transport", "# bytes transmitted via TCP"}, | 130 | { "transport", "# bytes transmitted via TCP" }, |
133 | {"datacache", "# bytes stored"}, | 131 | { "datacache", "# bytes stored" }, |
134 | {NULL, NULL} | 132 | { NULL, NULL } |
135 | }; | 133 | }; |
136 | 134 | ||
137 | 135 | ||
138 | static void | 136 | static void |
139 | cleanup () | 137 | cleanup() |
140 | { | 138 | { |
141 | GNUNET_SCHEDULER_shutdown (); | 139 | GNUNET_SCHEDULER_shutdown(); |
142 | if (NULL != fn1) | 140 | if (NULL != fn1) |
143 | { | 141 | { |
144 | GNUNET_DISK_directory_remove (fn1); | 142 | GNUNET_DISK_directory_remove(fn1); |
145 | GNUNET_free (fn1); | 143 | GNUNET_free(fn1); |
146 | } | 144 | } |
147 | if (NULL != fn2) | 145 | if (NULL != fn2) |
148 | { | 146 | { |
149 | GNUNET_DISK_directory_remove (fn2); | 147 | GNUNET_DISK_directory_remove(fn2); |
150 | GNUNET_free (fn2); | 148 | GNUNET_free(fn2); |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | 152 | ||
@@ -163,13 +161,13 @@ cleanup () | |||
163 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 161 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
164 | */ | 162 | */ |
165 | static int | 163 | static int |
166 | print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, | 164 | print_stat(void *cls, const char *subsystem, const char *name, uint64_t value, |
167 | int is_persistent) | 165 | int is_persistent) |
168 | { | 166 | { |
169 | struct StatMaster *sm = cls; | 167 | struct StatMaster *sm = cls; |
170 | 168 | ||
171 | fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, | 169 | fprintf(stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, |
172 | name, (unsigned long long) value); | 170 | name, (unsigned long long)value); |
173 | return GNUNET_OK; | 171 | return GNUNET_OK; |
174 | } | 172 | } |
175 | 173 | ||
@@ -178,23 +176,23 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
178 | * Function that gathers stats from all daemons. | 176 | * Function that gathers stats from all daemons. |
179 | */ | 177 | */ |
180 | static void | 178 | static void |
181 | stat_run (void *cls, | 179 | stat_run(void *cls, |
182 | struct GNUNET_TESTBED_Operation *op, | 180 | struct GNUNET_TESTBED_Operation *op, |
183 | void *ca_result, | 181 | void *ca_result, |
184 | const char *emsg); | 182 | const char *emsg); |
185 | 183 | ||
186 | 184 | ||
187 | /** | 185 | /** |
188 | * Function called when GET operation on stats is done. | 186 | * Function called when GET operation on stats is done. |
189 | */ | 187 | */ |
190 | static void | 188 | static void |
191 | get_done (void *cls, int success) | 189 | get_done(void *cls, int success) |
192 | { | 190 | { |
193 | struct StatMaster *sm = cls; | 191 | struct StatMaster *sm = cls; |
194 | 192 | ||
195 | GNUNET_break (GNUNET_OK == success); | 193 | GNUNET_break(GNUNET_OK == success); |
196 | sm->value++; | 194 | sm->value++; |
197 | stat_run (sm, sm->op, sm->stat, NULL); | 195 | stat_run(sm, sm->op, sm->stat, NULL); |
198 | } | 196 | } |
199 | 197 | ||
200 | 198 | ||
@@ -210,11 +208,11 @@ get_done (void *cls, int success) | |||
210 | * @return service handle to return in 'op_result', NULL on error | 208 | * @return service handle to return in 'op_result', NULL on error |
211 | */ | 209 | */ |
212 | static void * | 210 | static void * |
213 | statistics_connect_adapter (void *cls, | 211 | statistics_connect_adapter(void *cls, |
214 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 212 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
215 | { | 213 | { |
216 | return GNUNET_STATISTICS_create ("<driver>", | 214 | return GNUNET_STATISTICS_create("<driver>", |
217 | cfg); | 215 | cfg); |
218 | } | 216 | } |
219 | 217 | ||
220 | 218 | ||
@@ -226,10 +224,10 @@ statistics_connect_adapter (void *cls, | |||
226 | * @param op_result service handle returned from the connect adapter | 224 | * @param op_result service handle returned from the connect adapter |
227 | */ | 225 | */ |
228 | static void | 226 | static void |
229 | statistics_disconnect_adapter (void *cls, | 227 | statistics_disconnect_adapter(void *cls, |
230 | void *op_result) | 228 | void *op_result) |
231 | { | 229 | { |
232 | GNUNET_STATISTICS_destroy (op_result, GNUNET_NO); | 230 | GNUNET_STATISTICS_destroy(op_result, GNUNET_NO); |
233 | } | 231 | } |
234 | 232 | ||
235 | 233 | ||
@@ -237,49 +235,49 @@ statistics_disconnect_adapter (void *cls, | |||
237 | * Function that gathers stats from all daemons. | 235 | * Function that gathers stats from all daemons. |
238 | */ | 236 | */ |
239 | static void | 237 | static void |
240 | stat_run (void *cls, | 238 | stat_run(void *cls, |
241 | struct GNUNET_TESTBED_Operation *op, | 239 | struct GNUNET_TESTBED_Operation *op, |
242 | void *ca_result, | 240 | void *ca_result, |
243 | const char *emsg) | 241 | const char *emsg) |
244 | { | 242 | { |
245 | struct StatMaster *sm = cls; | 243 | struct StatMaster *sm = cls; |
246 | 244 | ||
247 | sm->stat = ca_result; | 245 | sm->stat = ca_result; |
248 | GNUNET_assert (NULL != sm->stat); | 246 | GNUNET_assert(NULL != sm->stat); |
249 | if (NULL != stats[sm->value].name) | 247 | if (NULL != stats[sm->value].name) |
250 | { | 248 | { |
251 | GNUNET_STATISTICS_get (sm->stat, | 249 | GNUNET_STATISTICS_get(sm->stat, |
252 | #if 0 | 250 | #if 0 |
253 | NULL, NULL, | 251 | NULL, NULL, |
254 | #else | 252 | #else |
255 | stats[sm->value].subsystem, stats[sm->value].name, | 253 | stats[sm->value].subsystem, stats[sm->value].name, |
256 | #endif | 254 | #endif |
257 | &get_done, &print_stat, | 255 | &get_done, &print_stat, |
258 | sm); | 256 | sm); |
259 | return; | 257 | return; |
260 | } | 258 | } |
261 | GNUNET_TESTBED_operation_done (sm->op); | 259 | GNUNET_TESTBED_operation_done(sm->op); |
262 | sm->value = 0; | 260 | sm->value = 0; |
263 | sm->daemon++; | 261 | sm->daemon++; |
264 | if (NUM_DAEMONS == sm->daemon) | 262 | if (NUM_DAEMONS == sm->daemon) |
265 | { | 263 | { |
266 | GNUNET_free (sm); | 264 | GNUNET_free(sm); |
267 | cleanup (); | 265 | cleanup(); |
268 | return; | 266 | return; |
269 | } | 267 | } |
270 | sm->op = | 268 | sm->op = |
271 | GNUNET_TESTBED_service_connect (NULL, | 269 | GNUNET_TESTBED_service_connect(NULL, |
272 | daemons[sm->daemon], | 270 | daemons[sm->daemon], |
273 | "statistics", | 271 | "statistics", |
274 | &stat_run, sm, | 272 | &stat_run, sm, |
275 | &statistics_connect_adapter, | 273 | &statistics_connect_adapter, |
276 | &statistics_disconnect_adapter, | 274 | &statistics_disconnect_adapter, |
277 | NULL); | 275 | NULL); |
278 | } | 276 | } |
279 | 277 | ||
280 | 278 | ||
281 | static void | 279 | static void |
282 | do_report (void *cls) | 280 | do_report(void *cls) |
283 | { | 281 | { |
284 | static int download_counter; | 282 | static int download_counter; |
285 | const char *type = cls; | 283 | const char *type = cls; |
@@ -288,62 +286,62 @@ do_report (void *cls) | |||
288 | struct StatMaster *sm; | 286 | struct StatMaster *sm; |
289 | 287 | ||
290 | if (0 == | 288 | if (0 == |
291 | GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time, | 289 | GNUNET_TIME_absolute_get_remaining(GNUNET_TIME_absolute_add(start_time, |
292 | TIMEOUT)).rel_value_us) | 290 | TIMEOUT)).rel_value_us) |
293 | { | 291 | { |
294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 292 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
295 | "Timeout during download for type `%s', shutting down with error\n", | 293 | "Timeout during download for type `%s', shutting down with error\n", |
296 | type); | 294 | type); |
297 | ok = 1; | 295 | ok = 1; |
298 | cleanup (); | 296 | cleanup(); |
299 | return; | 297 | return; |
300 | } | 298 | } |
301 | del = GNUNET_TIME_absolute_get_duration (start_time); | 299 | del = GNUNET_TIME_absolute_get_duration(start_time); |
302 | if (del.rel_value_us == 0) | 300 | if (del.rel_value_us == 0) |
303 | del.rel_value_us = 1; | 301 | del.rel_value_us = 1; |
304 | fancy = | 302 | fancy = |
305 | GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) * | 303 | GNUNET_STRINGS_byte_size_fancy(((unsigned long long)FILESIZE) * |
306 | 1000000LL / del.rel_value_us); | 304 | 1000000LL / del.rel_value_us); |
307 | fprintf (stderr, "Download speed of type `%s' was %s/s\n", type, fancy); | 305 | fprintf(stderr, "Download speed of type `%s' was %s/s\n", type, fancy); |
308 | GNUNET_free (fancy); | 306 | GNUNET_free(fancy); |
309 | if (NUM_DAEMONS != ++download_counter) | 307 | if (NUM_DAEMONS != ++download_counter) |
310 | return; /* more downloads to come */ | 308 | return; /* more downloads to come */ |
311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 309 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
312 | "Finished all downloads, getting statistics\n"); | 310 | "Finished all downloads, getting statistics\n"); |
313 | sm = GNUNET_new (struct StatMaster); | 311 | sm = GNUNET_new(struct StatMaster); |
314 | sm->op = | 312 | sm->op = |
315 | GNUNET_TESTBED_service_connect (NULL, | 313 | GNUNET_TESTBED_service_connect(NULL, |
316 | daemons[sm->daemon], | 314 | daemons[sm->daemon], |
317 | "statistics", | 315 | "statistics", |
318 | &stat_run, sm, | 316 | &stat_run, sm, |
319 | &statistics_connect_adapter, | 317 | &statistics_connect_adapter, |
320 | &statistics_disconnect_adapter, | 318 | &statistics_disconnect_adapter, |
321 | NULL); | 319 | NULL); |
322 | } | 320 | } |
323 | 321 | ||
324 | 322 | ||
325 | static void | 323 | static void |
326 | do_downloads (void *cls, const struct GNUNET_FS_Uri *u2, | 324 | do_downloads(void *cls, const struct GNUNET_FS_Uri *u2, |
327 | const char *fn) | 325 | const char *fn) |
328 | { | 326 | { |
329 | int anonymity; | 327 | int anonymity; |
330 | unsigned int i; | 328 | unsigned int i; |
331 | 329 | ||
332 | if (NULL == u2) | 330 | if (NULL == u2) |
333 | { | 331 | { |
334 | cleanup (); | 332 | cleanup(); |
335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 333 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
336 | "Timeout during upload attempt, shutting down with error\n"); | 334 | "Timeout during upload attempt, shutting down with error\n"); |
337 | ok = 1; | 335 | ok = 1; |
338 | return; | 336 | return; |
339 | } | 337 | } |
340 | if (NULL != fn) | 338 | if (NULL != fn) |
341 | fn2 = GNUNET_strdup (fn); | 339 | fn2 = GNUNET_strdup(fn); |
342 | uri2 = GNUNET_FS_uri_dup (u2); | 340 | uri2 = GNUNET_FS_uri_dup(u2); |
343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", | 341 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n", |
344 | (unsigned long long) FILESIZE); | 342 | (unsigned long long)FILESIZE); |
345 | start_time = GNUNET_TIME_absolute_get (); | 343 | start_time = GNUNET_TIME_absolute_get(); |
346 | if (NULL != strstr (progname, "dht")) | 344 | if (NULL != strstr(progname, "dht")) |
347 | anonymity = 0; | 345 | anonymity = 0; |
348 | else | 346 | else |
349 | anonymity = 1; | 347 | anonymity = 1; |
@@ -351,127 +349,127 @@ do_downloads (void *cls, const struct GNUNET_FS_Uri *u2, | |||
351 | * these peers do participate in sharing, they just | 349 | * these peers do participate in sharing, they just |
352 | * don't have to offer anything *initially*. */ | 350 | * don't have to offer anything *initially*. */ |
353 | for (i = 0; i < NUM_DAEMONS - 2; i++) | 351 | for (i = 0; i < NUM_DAEMONS - 2; i++) |
354 | GNUNET_FS_TEST_download (daemons[i], TIMEOUT, anonymity, | 352 | GNUNET_FS_TEST_download(daemons[i], TIMEOUT, anonymity, |
355 | 0 == (i % 2) ? SEED1 : SEED2, | 353 | 0 == (i % 2) ? SEED1 : SEED2, |
356 | 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report, | 354 | 0 == (i % 2) ? uri1 : uri2, VERBOSE, &do_report, |
357 | "leach"); | 355 | "leach"); |
358 | /* mutual downloads of (primary) sharing peers */ | 356 | /* mutual downloads of (primary) sharing peers */ |
359 | GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1, | 357 | GNUNET_FS_TEST_download(daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, SEED1, |
360 | uri1, VERBOSE, &do_report, "seeder 2"); | 358 | uri1, VERBOSE, &do_report, "seeder 2"); |
361 | GNUNET_FS_TEST_download (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2, | 359 | GNUNET_FS_TEST_download(daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, SEED2, |
362 | uri2, VERBOSE, &do_report, "seeder 1"); | 360 | uri2, VERBOSE, &do_report, "seeder 1"); |
363 | } | 361 | } |
364 | 362 | ||
365 | 363 | ||
366 | static void | 364 | static void |
367 | do_publish2 (void *cls, | 365 | do_publish2(void *cls, |
368 | const struct GNUNET_FS_Uri *u1, | 366 | const struct GNUNET_FS_Uri *u1, |
369 | const char *fn) | 367 | const char *fn) |
370 | { | 368 | { |
371 | int do_index; | 369 | int do_index; |
372 | int anonymity; | 370 | int anonymity; |
373 | 371 | ||
374 | if (NULL == u1) | 372 | if (NULL == u1) |
375 | { | 373 | { |
376 | cleanup (); | 374 | cleanup(); |
377 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 375 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
378 | "Timeout during upload attempt, shutting down with error\n"); | 376 | "Timeout during upload attempt, shutting down with error\n"); |
379 | ok = 1; | 377 | ok = 1; |
380 | return; | 378 | return; |
381 | } | 379 | } |
382 | if (NULL != fn) | 380 | if (NULL != fn) |
383 | fn1 = GNUNET_strdup (fn); | 381 | fn1 = GNUNET_strdup(fn); |
384 | uri1 = GNUNET_FS_uri_dup (u1); | 382 | uri1 = GNUNET_FS_uri_dup(u1); |
385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", | 383 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
386 | (unsigned long long) FILESIZE); | 384 | (unsigned long long)FILESIZE); |
387 | if (NULL != strstr (progname, "index")) | 385 | if (NULL != strstr(progname, "index")) |
388 | do_index = GNUNET_YES; | 386 | do_index = GNUNET_YES; |
389 | else | 387 | else |
390 | do_index = GNUNET_NO; | 388 | do_index = GNUNET_NO; |
391 | if (NULL != strstr (progname, "dht")) | 389 | if (NULL != strstr(progname, "dht")) |
392 | anonymity = 0; | 390 | anonymity = 0; |
393 | else | 391 | else |
394 | anonymity = 1; | 392 | anonymity = 1; |
395 | 393 | ||
396 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, | 394 | GNUNET_FS_TEST_publish(daemons[NUM_DAEMONS - 2], TIMEOUT, anonymity, |
397 | do_index, FILESIZE, SEED2, VERBOSE, &do_downloads, | 395 | do_index, FILESIZE, SEED2, VERBOSE, &do_downloads, |
398 | NULL); | 396 | NULL); |
399 | } | 397 | } |
400 | 398 | ||
401 | 399 | ||
402 | static void | 400 | static void |
403 | do_publish1 (void *cls, | 401 | do_publish1(void *cls, |
404 | struct GNUNET_TESTBED_Operation *op, | 402 | struct GNUNET_TESTBED_Operation *op, |
405 | const char *emsg) | 403 | const char *emsg) |
406 | { | 404 | { |
407 | unsigned int *coco = cls; | 405 | unsigned int *coco = cls; |
408 | int do_index; | 406 | int do_index; |
409 | int anonymity; | 407 | int anonymity; |
410 | 408 | ||
411 | GNUNET_TESTBED_operation_done (op); | 409 | GNUNET_TESTBED_operation_done(op); |
412 | if (NULL != emsg) | 410 | if (NULL != emsg) |
413 | { | 411 | { |
414 | cleanup (); | 412 | cleanup(); |
415 | 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); |
416 | ok = 1; | 414 | ok = 1; |
417 | return; | 415 | return; |
418 | } | 416 | } |
419 | if (0 != (--(*coco))) | 417 | if (0 != (--(*coco))) |
420 | return; /* more connections to be created */ | 418 | return; /* more connections to be created */ |
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", | 419 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n", |
422 | (unsigned long long) FILESIZE); | 420 | (unsigned long long)FILESIZE); |
423 | if (NULL != strstr (progname, "index")) | 421 | if (NULL != strstr(progname, "index")) |
424 | do_index = GNUNET_YES; | 422 | do_index = GNUNET_YES; |
425 | else | 423 | else |
426 | do_index = GNUNET_NO; | 424 | do_index = GNUNET_NO; |
427 | if (NULL != strstr (progname, "dht")) | 425 | if (NULL != strstr(progname, "dht")) |
428 | anonymity = 0; | 426 | anonymity = 0; |
429 | else | 427 | else |
430 | anonymity = 1; | 428 | anonymity = 1; |
431 | GNUNET_FS_TEST_publish (daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, | 429 | GNUNET_FS_TEST_publish(daemons[NUM_DAEMONS - 1], TIMEOUT, anonymity, |
432 | do_index, FILESIZE, SEED1, VERBOSE, &do_publish2, | 430 | do_index, FILESIZE, SEED1, VERBOSE, &do_publish2, |
433 | NULL); | 431 | NULL); |
434 | } | 432 | } |
435 | 433 | ||
436 | 434 | ||
437 | static void | 435 | static void |
438 | do_connect (void *cls, | 436 | do_connect(void *cls, |
439 | struct GNUNET_TESTBED_RunHandle *h, | 437 | struct GNUNET_TESTBED_RunHandle *h, |
440 | unsigned int num_peers, | 438 | unsigned int num_peers, |
441 | struct GNUNET_TESTBED_Peer **peers, | 439 | struct GNUNET_TESTBED_Peer **peers, |
442 | unsigned int links_succeeded, | 440 | unsigned int links_succeeded, |
443 | unsigned int links_failed) | 441 | unsigned int links_failed) |
444 | { | 442 | { |
445 | static unsigned int coco; | 443 | static unsigned int coco; |
446 | unsigned int i; | 444 | unsigned int i; |
447 | unsigned int j; | 445 | unsigned int j; |
448 | 446 | ||
449 | GNUNET_assert (NUM_DAEMONS == num_peers); | 447 | GNUNET_assert(NUM_DAEMONS == num_peers); |
450 | for (i=0;i<num_peers;i++) | 448 | for (i = 0; i < num_peers; i++) |
451 | daemons[i] = peers[i]; | 449 | daemons[i] = peers[i]; |
452 | for (i=0;i<NUM_DAEMONS;i++) | 450 | for (i = 0; i < NUM_DAEMONS; i++) |
453 | for (j=i+1;j<NUM_DAEMONS;j++) | 451 | for (j = i + 1; j < NUM_DAEMONS; j++) |
454 | { | 452 | { |
455 | coco++; | 453 | coco++; |
456 | GNUNET_TESTBED_overlay_connect (NULL, | 454 | GNUNET_TESTBED_overlay_connect(NULL, |
457 | &do_publish1, | 455 | &do_publish1, |
458 | &coco, | 456 | &coco, |
459 | peers[i], | 457 | peers[i], |
460 | peers[j]); | 458 | peers[j]); |
461 | } | 459 | } |
462 | } | 460 | } |
463 | 461 | ||
464 | 462 | ||
465 | int | 463 | int |
466 | main (int argc, char *argv[]) | 464 | main(int argc, char *argv[]) |
467 | { | 465 | { |
468 | progname = argv[0]; | 466 | progname = argv[0]; |
469 | (void) GNUNET_TESTBED_test_run ("perf-gnunet-service-fs-p2p-respect", | 467 | (void)GNUNET_TESTBED_test_run("perf-gnunet-service-fs-p2p-respect", |
470 | "perf_gnunet_service_fs_p2p.conf", | 468 | "perf_gnunet_service_fs_p2p.conf", |
471 | NUM_DAEMONS, | 469 | NUM_DAEMONS, |
472 | 0, NULL, NULL, | 470 | 0, NULL, NULL, |
473 | &do_connect, NULL); | 471 | &do_connect, NULL); |
474 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-lib/"); | 472 | GNUNET_DISK_directory_remove("/tmp/gnunet-test-fs-lib/"); |
475 | return ok; | 473 | return ok; |
476 | } | 474 | } |
477 | 475 | ||