diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/fs/gnunet-fs-profiler.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/fs/gnunet-fs-profiler.c')
-rw-r--r-- | src/fs/gnunet-fs-profiler.c | 151 |
1 files changed, 78 insertions, 73 deletions
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c index d47ca8b29..a6e248213 100644 --- a/src/fs/gnunet-fs-profiler.c +++ b/src/fs/gnunet-fs-profiler.c | |||
@@ -50,7 +50,7 @@ static struct GNUNET_TIME_Relative timeout; | |||
50 | /** | 50 | /** |
51 | * Handle to the task run during termination. | 51 | * Handle to the task run during termination. |
52 | */ | 52 | */ |
53 | static struct GNUNET_SCHEDULER_Task * terminate_taskid; | 53 | static struct GNUNET_SCHEDULER_Task *terminate_taskid; |
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
@@ -62,15 +62,15 @@ static struct GNUNET_SCHEDULER_Task * terminate_taskid; | |||
62 | * operation has executed successfully. | 62 | * operation has executed successfully. |
63 | */ | 63 | */ |
64 | static void | 64 | static void |
65 | shutdown_task(void *cls, | 65 | shutdown_task (void *cls, |
66 | struct GNUNET_TESTBED_Operation *op, | 66 | struct GNUNET_TESTBED_Operation *op, |
67 | const char *emsg) | 67 | const char *emsg) |
68 | { | 68 | { |
69 | if (NULL != emsg) | 69 | if (NULL != emsg) |
70 | fprintf(stderr, | 70 | fprintf (stderr, |
71 | "Error collecting statistics: %s\n", | 71 | "Error collecting statistics: %s\n", |
72 | emsg); | 72 | emsg); |
73 | GNUNET_SCHEDULER_shutdown(); | 73 | GNUNET_SCHEDULER_shutdown (); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
@@ -87,19 +87,19 @@ shutdown_task(void *cls, | |||
87 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 87 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
88 | */ | 88 | */ |
89 | static int | 89 | static int |
90 | process_stats(void *cls, | 90 | process_stats (void *cls, |
91 | const struct GNUNET_TESTBED_Peer *peer, | 91 | const struct GNUNET_TESTBED_Peer *peer, |
92 | const char *subsystem, | 92 | const char *subsystem, |
93 | const char *name, | 93 | const char *name, |
94 | uint64_t value, | 94 | uint64_t value, |
95 | int is_persistent) | 95 | int is_persistent) |
96 | { | 96 | { |
97 | fprintf(stdout, | 97 | fprintf (stdout, |
98 | "%p-%s: %s = %llu\n", | 98 | "%p-%s: %s = %llu\n", |
99 | peer, | 99 | peer, |
100 | subsystem, | 100 | subsystem, |
101 | name, | 101 | name, |
102 | (unsigned long long)value); | 102 | (unsigned long long) value); |
103 | return GNUNET_OK; | 103 | return GNUNET_OK; |
104 | } | 104 | } |
105 | 105 | ||
@@ -111,18 +111,18 @@ process_stats(void *cls, | |||
111 | * @param cls NULL | 111 | * @param cls NULL |
112 | */ | 112 | */ |
113 | static void | 113 | static void |
114 | terminate_task(void *cls) | 114 | terminate_task (void *cls) |
115 | { | 115 | { |
116 | if (NULL != terminate_taskid) | 116 | if (NULL != terminate_taskid) |
117 | { | 117 | { |
118 | GNUNET_SCHEDULER_cancel(terminate_taskid); | 118 | GNUNET_SCHEDULER_cancel (terminate_taskid); |
119 | terminate_taskid = NULL; | 119 | terminate_taskid = NULL; |
120 | } | 120 | } |
121 | GNUNET_TESTBED_get_statistics(0, NULL, | 121 | GNUNET_TESTBED_get_statistics (0, NULL, |
122 | NULL, NULL, | 122 | NULL, NULL, |
123 | &process_stats, | 123 | &process_stats, |
124 | &shutdown_task, | 124 | &shutdown_task, |
125 | NULL); | 125 | NULL); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
@@ -133,10 +133,10 @@ terminate_task(void *cls) | |||
133 | * @param cls NULL | 133 | * @param cls NULL |
134 | */ | 134 | */ |
135 | static void | 135 | static void |
136 | timeout_task(void *cls) | 136 | timeout_task (void *cls) |
137 | { | 137 | { |
138 | terminate_taskid = NULL; | 138 | terminate_taskid = NULL; |
139 | GNUNET_SCHEDULER_shutdown(); | 139 | GNUNET_SCHEDULER_shutdown (); |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
@@ -153,23 +153,23 @@ timeout_task(void *cls) | |||
153 | * failed | 153 | * failed |
154 | */ | 154 | */ |
155 | static void | 155 | static void |
156 | test_master(void *cls, | 156 | test_master (void *cls, |
157 | struct GNUNET_TESTBED_RunHandle *h, | 157 | struct GNUNET_TESTBED_RunHandle *h, |
158 | unsigned int num_peers, | 158 | unsigned int num_peers, |
159 | struct GNUNET_TESTBED_Peer **peers, | 159 | struct GNUNET_TESTBED_Peer **peers, |
160 | unsigned int links_succeeded, | 160 | unsigned int links_succeeded, |
161 | unsigned int links_failed) | 161 | unsigned int links_failed) |
162 | { | 162 | { |
163 | // const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 163 | // const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
164 | // FIXME: enable clients to signal 'completion' before timeout; | 164 | // FIXME: enable clients to signal 'completion' before timeout; |
165 | // in that case, run the 'terminate_task' "immediately" | 165 | // in that case, run the 'terminate_task' "immediately" |
166 | 166 | ||
167 | if (0 != timeout.rel_value_us) | 167 | if (0 != timeout.rel_value_us) |
168 | terminate_taskid = GNUNET_SCHEDULER_add_delayed(timeout, | 168 | terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout, |
169 | &timeout_task, | 169 | &timeout_task, |
170 | NULL); | 170 | NULL); |
171 | GNUNET_SCHEDULER_add_shutdown(&terminate_task, | 171 | GNUNET_SCHEDULER_add_shutdown (&terminate_task, |
172 | NULL); | 172 | NULL); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
@@ -182,14 +182,14 @@ test_master(void *cls, | |||
182 | * @param cfg configuration | 182 | * @param cfg configuration |
183 | */ | 183 | */ |
184 | static void | 184 | static void |
185 | run(void *cls, char *const *args, const char *cfgfile, | 185 | run (void *cls, char *const *args, const char *cfgfile, |
186 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 186 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
187 | { | 187 | { |
188 | GNUNET_TESTBED_run(host_filename, | 188 | GNUNET_TESTBED_run (host_filename, |
189 | cfg, | 189 | cfg, |
190 | num_peers, | 190 | num_peers, |
191 | 0, NULL, NULL, | 191 | 0, NULL, NULL, |
192 | &test_master, (void *)cfg); | 192 | &test_master, (void *) cfg); |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
@@ -201,38 +201,43 @@ run(void *cls, char *const *args, const char *cfgfile, | |||
201 | * @return 0 ok, 1 on error | 201 | * @return 0 ok, 1 on error |
202 | */ | 202 | */ |
203 | int | 203 | int |
204 | main(int argc, char *const *argv) | 204 | main (int argc, char *const *argv) |
205 | { | 205 | { |
206 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 206 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
207 | GNUNET_GETOPT_option_uint('n', | 207 | GNUNET_GETOPT_option_uint ('n', |
208 | "num-peers", | 208 | "num-peers", |
209 | "COUNT", | 209 | "COUNT", |
210 | gettext_noop("run the experiment with COUNT peers"), | 210 | gettext_noop ( |
211 | &num_peers), | 211 | "run the experiment with COUNT peers"), |
212 | 212 | &num_peers), | |
213 | GNUNET_GETOPT_option_string('H', | 213 | |
214 | "hosts", | 214 | GNUNET_GETOPT_option_string ('H', |
215 | "HOSTFILE", | 215 | "hosts", |
216 | gettext_noop("specifies name of a file with the HOSTS the testbed should use"), | 216 | "HOSTFILE", |
217 | &host_filename), | 217 | gettext_noop ( |
218 | 218 | "specifies name of a file with the HOSTS the testbed should use"), | |
219 | GNUNET_GETOPT_option_relative_time('t', | 219 | &host_filename), |
220 | "timeout", | 220 | |
221 | "DELAY", | 221 | GNUNET_GETOPT_option_relative_time ('t', |
222 | gettext_noop("automatically terminate experiment after DELAY"), | 222 | "timeout", |
223 | &timeout), | 223 | "DELAY", |
224 | gettext_noop ( | ||
225 | "automatically terminate experiment after DELAY"), | ||
226 | &timeout), | ||
224 | 227 | ||
225 | GNUNET_GETOPT_OPTION_END | 228 | GNUNET_GETOPT_OPTION_END |
226 | }; | 229 | }; |
227 | 230 | ||
228 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 231 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
229 | return 2; | 232 | return 2; |
230 | 233 | ||
231 | ret = (GNUNET_OK == | 234 | ret = (GNUNET_OK == |
232 | GNUNET_PROGRAM_run(argc, argv, "gnunet-fs-profiler", | 235 | GNUNET_PROGRAM_run (argc, argv, "gnunet-fs-profiler", |
233 | gettext_noop("run a testbed to measure file-sharing performance"), options, &run, | 236 | gettext_noop ( |
234 | NULL)) ? ret : 1; | 237 | "run a testbed to measure file-sharing performance"), |
235 | GNUNET_free((void*)argv); | 238 | options, &run, |
239 | NULL)) ? ret : 1; | ||
240 | GNUNET_free ((void*) argv); | ||
236 | return ret; | 241 | return ret; |
237 | } | 242 | } |
238 | 243 | ||