diff options
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r-- | src/core/test_core_api_reliability.c | 339 |
1 files changed, 158 insertions, 181 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index b279acb91..1f82a0058 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -71,7 +71,7 @@ struct PeerContext | |||
71 | { | 71 | { |
72 | struct GNUNET_CONFIGURATION_Handle *cfg; | 72 | struct GNUNET_CONFIGURATION_Handle *cfg; |
73 | struct GNUNET_CORE_Handle *ch; | 73 | struct GNUNET_CORE_Handle *ch; |
74 | struct GNUNET_PeerIdentity id; | 74 | struct GNUNET_PeerIdentity id; |
75 | struct GNUNET_TRANSPORT_Handle *th; | 75 | struct GNUNET_TRANSPORT_Handle *th; |
76 | struct GNUNET_MessageHeader *hello; | 76 | struct GNUNET_MessageHeader *hello; |
77 | int connect_status; | 77 | int connect_status; |
@@ -95,7 +95,7 @@ static int32_t tr_n; | |||
95 | #define OKPP do { ok++; } while (0) | 95 | #define OKPP do { ok++; } while (0) |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | struct TestMessage | 98 | struct TestMessage |
99 | { | 99 | { |
100 | struct GNUNET_MessageHeader header; | 100 | struct GNUNET_MessageHeader header; |
101 | uint32_t num; | 101 | uint32_t num; |
@@ -106,13 +106,15 @@ static unsigned int | |||
106 | get_size (unsigned int iter) | 106 | get_size (unsigned int iter) |
107 | { | 107 | { |
108 | unsigned int ret; | 108 | unsigned int ret; |
109 | |||
109 | if (iter < 60000) | 110 | if (iter < 60000) |
110 | return iter + sizeof (struct TestMessage); | 111 | return iter + sizeof (struct TestMessage); |
111 | ret = (iter * iter * iter); | 112 | ret = (iter * iter * iter); |
112 | return sizeof (struct TestMessage) + (ret % 60000); | 113 | return sizeof (struct TestMessage) + (ret % 60000); |
113 | } | 114 | } |
114 | 115 | ||
115 | static void process_hello (void *cls, const struct GNUNET_MessageHeader *message); | 116 | static void process_hello (void *cls, |
117 | const struct GNUNET_MessageHeader *message); | ||
116 | 118 | ||
117 | static void | 119 | static void |
118 | terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 120 | terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -131,9 +133,9 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
131 | p2.th = NULL; | 133 | p2.th = NULL; |
132 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 134 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
133 | fprintf (stderr, | 135 | fprintf (stderr, |
134 | "\nThroughput was %llu kb/s\n", | 136 | "\nThroughput was %llu kb/s\n", total_bytes * 1000 / 1024 / delta); |
135 | total_bytes * 1000 / 1024 / delta); | 137 | GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta, |
136 | GAUGER ("CORE", "Core throughput/s", total_bytes * 1000 / 1024 / delta, "kb/s"); | 138 | "kb/s"); |
137 | ok = 0; | 139 | ok = 0; |
138 | } | 140 | } |
139 | 141 | ||
@@ -143,27 +145,27 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
143 | { | 145 | { |
144 | GNUNET_break (0); | 146 | GNUNET_break (0); |
145 | if (p1.ch != NULL) | 147 | if (p1.ch != NULL) |
146 | { | 148 | { |
147 | GNUNET_CORE_disconnect (p1.ch); | 149 | GNUNET_CORE_disconnect (p1.ch); |
148 | p1.ch = NULL; | 150 | p1.ch = NULL; |
149 | } | 151 | } |
150 | if (p2.ch != NULL) | 152 | if (p2.ch != NULL) |
151 | { | 153 | { |
152 | GNUNET_CORE_disconnect (p2.ch); | 154 | GNUNET_CORE_disconnect (p2.ch); |
153 | p2.ch = NULL; | 155 | p2.ch = NULL; |
154 | } | 156 | } |
155 | if (p1.th != NULL) | 157 | if (p1.th != NULL) |
156 | { | 158 | { |
157 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1); | 159 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1); |
158 | GNUNET_TRANSPORT_disconnect (p1.th); | 160 | GNUNET_TRANSPORT_disconnect (p1.th); |
159 | p1.th = NULL; | 161 | p1.th = NULL; |
160 | } | 162 | } |
161 | if (p2.th != NULL) | 163 | if (p2.th != NULL) |
162 | { | 164 | { |
163 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2); | 165 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2); |
164 | GNUNET_TRANSPORT_disconnect (p2.th); | 166 | GNUNET_TRANSPORT_disconnect (p2.th); |
165 | p2.th = NULL; | 167 | p2.th = NULL; |
166 | } | 168 | } |
167 | ok = 42; | 169 | ok = 42; |
168 | } | 170 | } |
169 | 171 | ||
@@ -176,20 +178,20 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
176 | unsigned int s; | 178 | unsigned int s; |
177 | unsigned int ret; | 179 | unsigned int ret; |
178 | 180 | ||
179 | GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); | 181 | GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE); |
180 | if (buf == NULL) | 182 | if (buf == NULL) |
181 | { | 183 | { |
182 | if (p1.ch != NULL) | 184 | if (p1.ch != NULL) |
183 | GNUNET_break (NULL != | 185 | GNUNET_break (NULL != |
184 | GNUNET_CORE_notify_transmit_ready (p1.ch, | 186 | GNUNET_CORE_notify_transmit_ready (p1.ch, |
185 | GNUNET_NO, | 187 | GNUNET_NO, |
186 | 0, | 188 | 0, |
187 | FAST_TIMEOUT, | 189 | FAST_TIMEOUT, |
188 | &p2.id, | 190 | &p2.id, |
189 | get_size(tr_n), | 191 | get_size (tr_n), |
190 | &transmit_ready, &p1)); | 192 | &transmit_ready, &p1)); |
191 | return 0; | 193 | return 0; |
192 | } | 194 | } |
193 | GNUNET_assert (tr_n < TOTAL_MSGS); | 195 | GNUNET_assert (tr_n < TOTAL_MSGS); |
194 | ret = 0; | 196 | ret = 0; |
195 | s = get_size (tr_n); | 197 | s = get_size (tr_n); |
@@ -197,35 +199,29 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
197 | GNUNET_assert (buf != NULL); | 199 | GNUNET_assert (buf != NULL); |
198 | cbuf = buf; | 200 | cbuf = buf; |
199 | do | 201 | do |
200 | { | 202 | { |
201 | #if VERBOSE | 203 | #if VERBOSE |
202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
203 | "Sending message %u of size %u at offset %u\n", | 205 | "Sending message %u of size %u at offset %u\n", tr_n, s, ret); |
204 | tr_n, | ||
205 | s, | ||
206 | ret); | ||
207 | #endif | 206 | #endif |
208 | hdr.header.size = htons (s); | 207 | hdr.header.size = htons (s); |
209 | hdr.header.type = htons (MTYPE); | 208 | hdr.header.type = htons (MTYPE); |
210 | hdr.num = htonl (tr_n); | 209 | hdr.num = htonl (tr_n); |
211 | memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); | 210 | memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage)); |
212 | ret += sizeof (struct TestMessage); | 211 | ret += sizeof (struct TestMessage); |
213 | memset (&cbuf[ret], tr_n, s - sizeof (struct TestMessage)); | 212 | memset (&cbuf[ret], tr_n, s - sizeof (struct TestMessage)); |
214 | ret += s - sizeof (struct TestMessage); | 213 | ret += s - sizeof (struct TestMessage); |
215 | tr_n++; | 214 | tr_n++; |
216 | s = get_size (tr_n); | 215 | s = get_size (tr_n); |
217 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) | 216 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) |
218 | break; /* sometimes pack buffer full, sometimes not */ | 217 | break; /* sometimes pack buffer full, sometimes not */ |
219 | } | 218 | } |
220 | while (size - ret >= s); | 219 | while (size - ret >= s); |
221 | GNUNET_SCHEDULER_cancel (err_task); | 220 | GNUNET_SCHEDULER_cancel (err_task); |
222 | err_task = | 221 | err_task = |
223 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 222 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
224 | &terminate_task_error, | ||
225 | NULL); | ||
226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
227 | "Returning total message block of size %u\n", | 224 | "Returning total message block of size %u\n", ret); |
228 | ret); | ||
229 | total_bytes += ret; | 225 | total_bytes += ret; |
230 | return ret; | 226 | return ret; |
231 | } | 227 | } |
@@ -235,51 +231,44 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
235 | static void | 231 | static void |
236 | connect_notify (void *cls, | 232 | connect_notify (void *cls, |
237 | const struct GNUNET_PeerIdentity *peer, | 233 | const struct GNUNET_PeerIdentity *peer, |
238 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 234 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
239 | { | 235 | { |
240 | struct PeerContext *pc = cls; | 236 | struct PeerContext *pc = cls; |
241 | 237 | ||
242 | if (0 == memcmp (&pc->id, | 238 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
243 | peer, | ||
244 | sizeof (struct GNUNET_PeerIdentity))) | ||
245 | return; | 239 | return; |
246 | GNUNET_assert (pc->connect_status == 0); | 240 | GNUNET_assert (pc->connect_status == 0); |
247 | pc->connect_status = 1; | 241 | pc->connect_status = 1; |
248 | if (pc == &p1) | 242 | if (pc == &p1) |
249 | { | 243 | { |
250 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
251 | "Encrypted connection established to peer `%4s'\n", | 245 | "Encrypted connection established to peer `%4s'\n", |
252 | GNUNET_i2s (peer)); | 246 | GNUNET_i2s (peer)); |
253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
254 | "Asking core (1) for transmission to peer `%4s'\n", | 248 | "Asking core (1) for transmission to peer `%4s'\n", |
255 | GNUNET_i2s (&p2.id)); | 249 | GNUNET_i2s (&p2.id)); |
256 | GNUNET_SCHEDULER_cancel (err_task); | 250 | GNUNET_SCHEDULER_cancel (err_task); |
257 | err_task = | 251 | err_task = |
258 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 252 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
259 | &terminate_task_error, | 253 | start_time = GNUNET_TIME_absolute_get (); |
260 | NULL); | 254 | GNUNET_break (NULL != |
261 | start_time = GNUNET_TIME_absolute_get (); | 255 | GNUNET_CORE_notify_transmit_ready (p1.ch, |
262 | GNUNET_break (NULL != | 256 | GNUNET_NO, |
263 | GNUNET_CORE_notify_transmit_ready (p1.ch, | 257 | 0, |
264 | GNUNET_NO, | 258 | TIMEOUT, |
265 | 0, | 259 | &p2.id, |
266 | TIMEOUT, | 260 | get_size (0), |
267 | &p2.id, | 261 | &transmit_ready, &p1)); |
268 | get_size (0), | 262 | } |
269 | &transmit_ready, &p1)); | ||
270 | } | ||
271 | } | 263 | } |
272 | 264 | ||
273 | 265 | ||
274 | static void | 266 | static void |
275 | disconnect_notify (void *cls, | 267 | disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) |
276 | const struct GNUNET_PeerIdentity *peer) | ||
277 | { | 268 | { |
278 | struct PeerContext *pc = cls; | 269 | struct PeerContext *pc = cls; |
279 | 270 | ||
280 | if (0 == memcmp (&pc->id, | 271 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
281 | peer, | ||
282 | sizeof (struct GNUNET_PeerIdentity))) | ||
283 | return; | 272 | return; |
284 | pc->connect_status = 0; | 273 | pc->connect_status = 0; |
285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -291,7 +280,7 @@ static int | |||
291 | inbound_notify (void *cls, | 280 | inbound_notify (void *cls, |
292 | const struct GNUNET_PeerIdentity *other, | 281 | const struct GNUNET_PeerIdentity *other, |
293 | const struct GNUNET_MessageHeader *message, | 282 | const struct GNUNET_MessageHeader *message, |
294 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 283 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
295 | { | 284 | { |
296 | #if VERBOSE | 285 | #if VERBOSE |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -305,7 +294,7 @@ static int | |||
305 | outbound_notify (void *cls, | 294 | outbound_notify (void *cls, |
306 | const struct GNUNET_PeerIdentity *other, | 295 | const struct GNUNET_PeerIdentity *other, |
307 | const struct GNUNET_MessageHeader *message, | 296 | const struct GNUNET_MessageHeader *message, |
308 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 297 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
309 | { | 298 | { |
310 | #if VERBOSE | 299 | #if VERBOSE |
311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -316,71 +305,65 @@ outbound_notify (void *cls, | |||
316 | } | 305 | } |
317 | 306 | ||
318 | 307 | ||
319 | static size_t | 308 | static size_t transmit_ready (void *cls, size_t size, void *buf); |
320 | transmit_ready (void *cls, size_t size, void *buf); | ||
321 | 309 | ||
322 | static int | 310 | static int |
323 | process_mtype (void *cls, | 311 | process_mtype (void *cls, |
324 | const struct GNUNET_PeerIdentity *peer, | 312 | const struct GNUNET_PeerIdentity *peer, |
325 | const struct GNUNET_MessageHeader *message, | 313 | const struct GNUNET_MessageHeader *message, |
326 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 314 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
327 | { | 315 | { |
328 | static int n; | 316 | static int n; |
329 | unsigned int s; | 317 | unsigned int s; |
330 | const struct TestMessage *hdr; | 318 | const struct TestMessage *hdr; |
331 | 319 | ||
332 | hdr = (const struct TestMessage*) message; | 320 | hdr = (const struct TestMessage *) message; |
333 | s = get_size (n); | 321 | s = get_size (n); |
334 | if (MTYPE != ntohs (message->type)) | 322 | if (MTYPE != ntohs (message->type)) |
335 | return GNUNET_SYSERR; | 323 | return GNUNET_SYSERR; |
336 | if (ntohs (message->size) != s) | 324 | if (ntohs (message->size) != s) |
337 | { | 325 | { |
338 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
339 | "Expected message %u of size %u, got %u bytes of message %u\n", | 327 | "Expected message %u of size %u, got %u bytes of message %u\n", |
340 | n, s, | 328 | n, s, ntohs (message->size), ntohl (hdr->num)); |
341 | ntohs (message->size), | 329 | GNUNET_SCHEDULER_cancel (err_task); |
342 | ntohl (hdr->num)); | 330 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); |
343 | GNUNET_SCHEDULER_cancel (err_task); | 331 | return GNUNET_SYSERR; |
344 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); | 332 | } |
345 | return GNUNET_SYSERR; | ||
346 | } | ||
347 | if (ntohl (hdr->num) != n) | 333 | if (ntohl (hdr->num) != n) |
348 | { | 334 | { |
349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
350 | "Expected message %u of size %u, got %u bytes of message %u\n", | 336 | "Expected message %u of size %u, got %u bytes of message %u\n", |
351 | n, s, | 337 | n, s, ntohs (message->size), ntohl (hdr->num)); |
352 | ntohs (message->size), | 338 | GNUNET_SCHEDULER_cancel (err_task); |
353 | ntohl (hdr->num)); | 339 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); |
354 | GNUNET_SCHEDULER_cancel (err_task); | 340 | return GNUNET_SYSERR; |
355 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); | 341 | } |
356 | return GNUNET_SYSERR; | ||
357 | } | ||
358 | #if VERBOSE | 342 | #if VERBOSE |
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
360 | "Got message %u of size %u\n", | 344 | "Got message %u of size %u\n", |
361 | ntohl (hdr->num), | 345 | ntohl (hdr->num), ntohs (message->size)); |
362 | ntohs (message->size)); | ||
363 | #endif | 346 | #endif |
364 | n++; | 347 | n++; |
365 | if (0 == (n % (TOTAL_MSGS/100))) | 348 | if (0 == (n % (TOTAL_MSGS / 100))) |
366 | fprintf (stderr, "."); | 349 | fprintf (stderr, "."); |
367 | if (n == TOTAL_MSGS) | 350 | if (n == TOTAL_MSGS) |
368 | { | 351 | { |
369 | GNUNET_SCHEDULER_cancel (err_task); | 352 | GNUNET_SCHEDULER_cancel (err_task); |
370 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | 353 | GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
371 | } | 354 | } |
372 | else | 355 | else |
373 | { | 356 | { |
374 | if (n == tr_n) | 357 | if (n == tr_n) |
375 | GNUNET_break (NULL != | 358 | GNUNET_break (NULL != |
376 | GNUNET_CORE_notify_transmit_ready (p1.ch, | 359 | GNUNET_CORE_notify_transmit_ready (p1.ch, |
377 | GNUNET_NO, | 360 | GNUNET_NO, |
378 | 0, | 361 | 0, |
379 | FAST_TIMEOUT, | 362 | FAST_TIMEOUT, |
380 | &p2.id, | 363 | &p2.id, |
381 | get_size(tr_n), | 364 | get_size (tr_n), |
382 | &transmit_ready, &p1)); | 365 | &transmit_ready, &p1)); |
383 | } | 366 | } |
384 | return GNUNET_OK; | 367 | return GNUNET_OK; |
385 | } | 368 | } |
386 | 369 | ||
@@ -407,44 +390,39 @@ init_notify (void *cls, | |||
407 | p->id = *my_identity; | 390 | p->id = *my_identity; |
408 | p->ch = server; | 391 | p->ch = server; |
409 | if (cls == &p1) | 392 | if (cls == &p1) |
410 | { | 393 | { |
411 | GNUNET_assert (ok == 2); | 394 | GNUNET_assert (ok == 2); |
412 | OKPP; | 395 | OKPP; |
413 | /* connect p2 */ | 396 | /* connect p2 */ |
414 | GNUNET_CORE_connect (p2.cfg, 1, | 397 | GNUNET_CORE_connect (p2.cfg, 1, |
415 | &p2, | 398 | &p2, |
416 | &init_notify, | 399 | &init_notify, |
417 | &connect_notify, | 400 | &connect_notify, |
418 | &disconnect_notify, | 401 | &disconnect_notify, |
419 | NULL, | 402 | NULL, |
420 | &inbound_notify, | 403 | &inbound_notify, |
421 | GNUNET_YES, | 404 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
422 | &outbound_notify, GNUNET_YES, handlers); | 405 | } |
423 | } | ||
424 | else | 406 | else |
425 | { | 407 | { |
426 | GNUNET_assert (ok == 3); | 408 | GNUNET_assert (ok == 3); |
427 | OKPP; | 409 | OKPP; |
428 | GNUNET_assert (cls == &p2); | 410 | GNUNET_assert (cls == &p2); |
429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
430 | "Asking core (1) to connect to peer `%4s'\n", | 412 | "Asking core (1) to connect to peer `%4s'\n", |
431 | GNUNET_i2s (&p2.id)); | 413 | GNUNET_i2s (&p2.id)); |
432 | GNUNET_CORE_peer_request_connect (p1.ch, | 414 | GNUNET_CORE_peer_request_connect (p1.ch, &p2.id, NULL, NULL); |
433 | &p2.id, | 415 | } |
434 | NULL, NULL); | ||
435 | } | ||
436 | } | 416 | } |
437 | 417 | ||
438 | 418 | ||
439 | static void | 419 | static void |
440 | process_hello (void *cls, | 420 | process_hello (void *cls, const struct GNUNET_MessageHeader *message) |
441 | const struct GNUNET_MessageHeader *message) | ||
442 | { | 421 | { |
443 | struct PeerContext *p = cls; | 422 | struct PeerContext *p = cls; |
444 | 423 | ||
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
446 | "Received (my) `%s' from transport service\n", | 425 | "Received (my) `%s' from transport service\n", "HELLO"); |
447 | "HELLO"); | ||
448 | GNUNET_assert (message != NULL); | 426 | GNUNET_assert (message != NULL); |
449 | p->hello = GNUNET_malloc (ntohs (message->size)); | 427 | p->hello = GNUNET_malloc (ntohs (message->size)); |
450 | memcpy (p->hello, message, ntohs (message->size)); | 428 | memcpy (p->hello, message, ntohs (message->size)); |
@@ -467,11 +445,11 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
467 | p->cfg = GNUNET_CONFIGURATION_create (); | 445 | p->cfg = GNUNET_CONFIGURATION_create (); |
468 | #if START_ARM | 446 | #if START_ARM |
469 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 447 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
470 | "gnunet-service-arm", | 448 | "gnunet-service-arm", |
471 | #if VERBOSE | 449 | #if VERBOSE |
472 | "-L", "DEBUG", | 450 | "-L", "DEBUG", |
473 | #endif | 451 | #endif |
474 | "-c", cfgname, NULL); | 452 | "-c", cfgname, NULL); |
475 | #endif | 453 | #endif |
476 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 454 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
477 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | 455 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); |
@@ -483,23 +461,20 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
483 | static void | 461 | static void |
484 | run (void *cls, | 462 | run (void *cls, |
485 | char *const *args, | 463 | char *const *args, |
486 | const char *cfgfile, | 464 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
487 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
488 | { | 465 | { |
489 | GNUNET_assert (ok == 1); | 466 | GNUNET_assert (ok == 1); |
490 | OKPP; | 467 | OKPP; |
491 | setup_peer (&p1, "test_core_api_peer1.conf"); | 468 | setup_peer (&p1, "test_core_api_peer1.conf"); |
492 | setup_peer (&p2, "test_core_api_peer2.conf"); | 469 | setup_peer (&p2, "test_core_api_peer2.conf"); |
493 | err_task = | 470 | err_task = |
494 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 471 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); |
495 | &terminate_task_error, | ||
496 | NULL); | ||
497 | GNUNET_CORE_connect (p1.cfg, 1, | 472 | GNUNET_CORE_connect (p1.cfg, 1, |
498 | &p1, | 473 | &p1, |
499 | &init_notify, | 474 | &init_notify, |
500 | &connect_notify, | 475 | &connect_notify, |
501 | &disconnect_notify, | 476 | &disconnect_notify, |
502 | NULL, | 477 | NULL, |
503 | &inbound_notify, | 478 | &inbound_notify, |
504 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 479 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
505 | } | 480 | } |
@@ -511,10 +486,11 @@ stop_arm (struct PeerContext *p) | |||
511 | #if START_ARM | 486 | #if START_ARM |
512 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | 487 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) |
513 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 488 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
514 | if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK) | 489 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
515 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | 490 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); |
516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 491 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
517 | "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc)); | 492 | "ARM process %u stopped\n", |
493 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
518 | GNUNET_OS_process_close (p->arm_proc); | 494 | GNUNET_OS_process_close (p->arm_proc); |
519 | p->arm_proc = NULL; | 495 | p->arm_proc = NULL; |
520 | #endif | 496 | #endif |
@@ -537,7 +513,8 @@ check () | |||
537 | }; | 513 | }; |
538 | ok = 1; | 514 | ok = 1; |
539 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 515 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
540 | argv, "test-core-api-reliability", "nohelp", options, &run, &ok); | 516 | argv, "test-core-api-reliability", "nohelp", options, |
517 | &run, &ok); | ||
541 | stop_arm (&p1); | 518 | stop_arm (&p1); |
542 | stop_arm (&p2); | 519 | stop_arm (&p2); |
543 | return ok; | 520 | return ok; |
@@ -556,7 +533,7 @@ main (int argc, char *argv[]) | |||
556 | #endif | 533 | #endif |
557 | NULL); | 534 | NULL); |
558 | ret = check (); | 535 | ret = check (); |
559 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 536 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); |
560 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); | 537 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2"); |
561 | 538 | ||
562 | return ret; | 539 | return ret; |