diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-04 21:05:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-04 21:05:10 +0200 |
commit | 14537ef71b43ac47fe342c4e88f7bd3675ed1e39 (patch) | |
tree | 6833f549f695ba40533ba716caebc1866415e359 /src/transport/transport-testing2.c | |
parent | 0e6553e41d132726eb8f7964b581bb2cac0e6b6c (diff) | |
download | gnunet-14537ef71b43ac47fe342c4e88f7bd3675ed1e39.tar.gz gnunet-14537ef71b43ac47fe342c4e88f7bd3675ed1e39.zip |
misc bugfixes
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r-- | src/transport/transport-testing2.c | 209 |
1 files changed, 98 insertions, 111 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 2abe6c9ce..9bbd15983 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include "transport.h" | 35 | #include "transport.h" |
36 | 36 | ||
37 | 37 | ||
38 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__) | 38 | #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__) |
39 | 39 | ||
40 | 40 | ||
41 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | 41 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle |
@@ -110,7 +110,8 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | |||
110 | /** | 110 | /** |
111 | * @brief Callback called when a new communicator connects | 111 | * @brief Callback called when a new communicator connects |
112 | */ | 112 | */ |
113 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb; | 113 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback |
114 | communicator_available_cb; | ||
114 | 115 | ||
115 | /** | 116 | /** |
116 | * @brief Callback called when a new communicator connects | 117 | * @brief Callback called when a new communicator connects |
@@ -203,8 +204,9 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission | |||
203 | * @return GNUNET_YES in case message is correct | 204 | * @return GNUNET_YES in case message is correct |
204 | */ | 205 | */ |
205 | static int | 206 | static int |
206 | check_communicator_available (void *cls, | 207 | check_communicator_available ( |
207 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) | 208 | void *cls, |
209 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) | ||
208 | { | 210 | { |
209 | uint16_t size; | 211 | uint16_t size; |
210 | 212 | ||
@@ -223,8 +225,9 @@ check_communicator_available (void *cls, | |||
223 | * @param msg Message struct | 225 | * @param msg Message struct |
224 | */ | 226 | */ |
225 | static void | 227 | static void |
226 | handle_communicator_available (void *cls, | 228 | handle_communicator_available ( |
227 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) | 229 | void *cls, |
230 | const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) | ||
228 | { | 231 | { |
229 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 232 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
230 | uint16_t size; | 233 | uint16_t size; |
@@ -236,8 +239,7 @@ handle_communicator_available (void *cls, | |||
236 | tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]); | 239 | tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]); |
237 | if (NULL != tc_h->communicator_available_cb) | 240 | if (NULL != tc_h->communicator_available_cb) |
238 | { | 241 | { |
239 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 242 | LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n"); |
240 | "calling communicator_available_cb()\n"); | ||
241 | tc_h->communicator_available_cb (tc_h->cb_cls, | 243 | tc_h->communicator_available_cb (tc_h->cb_cls, |
242 | tc_h, | 244 | tc_h, |
243 | tc_h->c_characteristics, | 245 | tc_h->c_characteristics, |
@@ -283,8 +285,7 @@ handle_add_address (void *cls, | |||
283 | tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]); | 285 | tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]); |
284 | if (NULL != tc_h->add_address_cb) | 286 | if (NULL != tc_h->add_address_cb) |
285 | { | 287 | { |
286 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 288 | LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available()\n"); |
287 | "calling communicator_available()\n"); | ||
288 | tc_h->add_address_cb (tc_h->cb_cls, | 289 | tc_h->add_address_cb (tc_h->cb_cls, |
289 | tc_h, | 290 | tc_h, |
290 | tc_h->c_address, | 291 | tc_h->c_address, |
@@ -304,25 +305,22 @@ handle_queue_create_ok (void *cls, | |||
304 | 305 | ||
305 | if (NULL != tc_h->queue_create_reply_cb) | 306 | if (NULL != tc_h->queue_create_reply_cb) |
306 | { | 307 | { |
307 | tc_h->queue_create_reply_cb (tc_h->cb_cls, | 308 | tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES); |
308 | tc_h, | ||
309 | GNUNET_YES); | ||
310 | } | 309 | } |
311 | GNUNET_SERVICE_client_continue (tc_h->client); | 310 | GNUNET_SERVICE_client_continue (tc_h->client); |
312 | } | 311 | } |
313 | 312 | ||
314 | 313 | ||
315 | static void | 314 | static void |
316 | handle_queue_create_fail (void *cls, | 315 | handle_queue_create_fail ( |
317 | const struct GNUNET_TRANSPORT_CreateQueueResponse *msg) | 316 | void *cls, |
317 | const struct GNUNET_TRANSPORT_CreateQueueResponse *msg) | ||
318 | { | 318 | { |
319 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 319 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
320 | 320 | ||
321 | if (NULL != tc_h->queue_create_reply_cb) | 321 | if (NULL != tc_h->queue_create_reply_cb) |
322 | { | 322 | { |
323 | tc_h->queue_create_reply_cb (tc_h->cb_cls, | 323 | tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO); |
324 | tc_h, | ||
325 | GNUNET_NO); | ||
326 | } | 324 | } |
327 | GNUNET_SERVICE_client_continue (tc_h->client); | 325 | GNUNET_SERVICE_client_continue (tc_h->client); |
328 | } | 326 | } |
@@ -362,16 +360,13 @@ handle_add_queue_message (void *cls, | |||
362 | tc_queue = tc_queue->next; | 360 | tc_queue = tc_queue->next; |
363 | } | 361 | } |
364 | GNUNET_assert (tc_queue->qid == msg->qid); | 362 | GNUNET_assert (tc_queue->qid == msg->qid); |
365 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, | 363 | GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver)); |
366 | &msg->receiver)); | ||
367 | tc_queue->nt = msg->nt; | 364 | tc_queue->nt = msg->nt; |
368 | tc_queue->mtu = msg->mtu; | 365 | tc_queue->mtu = msg->mtu; |
369 | tc_queue->cs = msg->cs; | 366 | tc_queue->cs = msg->cs; |
370 | if (NULL != tc_h->add_queue_cb) | 367 | if (NULL != tc_h->add_queue_cb) |
371 | { | 368 | { |
372 | tc_h->add_queue_cb (tc_h->cb_cls, | 369 | tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue); |
373 | tc_h, | ||
374 | tc_queue); | ||
375 | } | 370 | } |
376 | GNUNET_SERVICE_client_continue (tc_h->client); | 371 | GNUNET_SERVICE_client_continue (tc_h->client); |
377 | } | 372 | } |
@@ -408,17 +403,17 @@ connect_cb (void *cls, | |||
408 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 403 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
409 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter; | 404 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter; |
410 | 405 | ||
411 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 406 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n"); |
412 | "Client connected.\n"); | ||
413 | tc_h->client = client; | 407 | tc_h->client = client; |
414 | tc_h->c_mq = mq; | 408 | tc_h->c_mq = mq; |
415 | 409 | ||
416 | if (NULL == tc_h->queue_head) return tc_h; | 410 | if (NULL == tc_h->queue_head) |
411 | return tc_h; | ||
417 | while (NULL != (tc_queue_iter = tc_h->queue_head)) | 412 | while (NULL != (tc_queue_iter = tc_h->queue_head)) |
418 | { | 413 | { |
419 | if (NULL == tc_queue_iter->open_queue_env) continue; | 414 | if (NULL == tc_queue_iter->open_queue_env) |
420 | GNUNET_MQ_send (tc_h->c_mq, | 415 | continue; |
421 | tc_queue_iter->open_queue_env); | 416 | GNUNET_MQ_send (tc_h->c_mq, tc_queue_iter->open_queue_env); |
422 | tc_queue_iter->open_queue_env = NULL; | 417 | tc_queue_iter->open_queue_env = NULL; |
423 | } | 418 | } |
424 | return tc_h; | 419 | return tc_h; |
@@ -439,8 +434,7 @@ disconnect_cb (void *cls, | |||
439 | { | 434 | { |
440 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 435 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
441 | 436 | ||
442 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 437 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n"); |
443 | "Client disconnected.\n"); | ||
444 | tc_h->client = NULL; | 438 | tc_h->client = NULL; |
445 | } | 439 | } |
446 | 440 | ||
@@ -453,21 +447,22 @@ disconnect_cb (void *cls, | |||
453 | * @param cfg Configuration | 447 | * @param cfg Configuration |
454 | */ | 448 | */ |
455 | static void | 449 | static void |
456 | transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | 450 | transport_communicator_start ( |
451 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | ||
457 | { | 452 | { |
458 | struct GNUNET_MQ_MessageHandler mh[] = { | 453 | struct GNUNET_MQ_MessageHandler mh[] = { |
459 | GNUNET_MQ_hd_var_size (communicator_available, | 454 | GNUNET_MQ_hd_var_size (communicator_available, |
460 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, | 455 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, |
461 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, | 456 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, |
462 | &tc_h), | 457 | &tc_h), |
463 | //GNUNET_MQ_hd_var_size (communicator_backchannel, | 458 | //GNUNET_MQ_hd_var_size (communicator_backchannel, |
464 | // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, | 459 | // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, |
465 | // struct GNUNET_TRANSPORT_CommunicatorBackchannel, | 460 | // struct GNUNET_TRANSPORT_CommunicatorBackchannel, |
466 | // NULL), | 461 | // NULL), |
467 | GNUNET_MQ_hd_var_size (add_address, | 462 | GNUNET_MQ_hd_var_size (add_address, |
468 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, | 463 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, |
469 | struct GNUNET_TRANSPORT_AddAddressMessage, | 464 | struct GNUNET_TRANSPORT_AddAddressMessage, |
470 | &tc_h), | 465 | &tc_h), |
471 | //GNUNET_MQ_hd_fixed_size (del_address, | 466 | //GNUNET_MQ_hd_fixed_size (del_address, |
472 | // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, | 467 | // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, |
473 | // struct GNUNET_TRANSPORT_DelAddressMessage, | 468 | // struct GNUNET_TRANSPORT_DelAddressMessage, |
@@ -477,17 +472,17 @@ transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunica | |||
477 | // struct GNUNET_TRANSPORT_IncomingMessage, | 472 | // struct GNUNET_TRANSPORT_IncomingMessage, |
478 | // NULL), | 473 | // NULL), |
479 | GNUNET_MQ_hd_fixed_size (queue_create_ok, | 474 | GNUNET_MQ_hd_fixed_size (queue_create_ok, |
480 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, | 475 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, |
481 | struct GNUNET_TRANSPORT_CreateQueueResponse, | 476 | struct GNUNET_TRANSPORT_CreateQueueResponse, |
482 | tc_h), | 477 | tc_h), |
483 | GNUNET_MQ_hd_fixed_size (queue_create_fail, | 478 | GNUNET_MQ_hd_fixed_size (queue_create_fail, |
484 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, | 479 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL, |
485 | struct GNUNET_TRANSPORT_CreateQueueResponse, | 480 | struct GNUNET_TRANSPORT_CreateQueueResponse, |
486 | tc_h), | 481 | tc_h), |
487 | GNUNET_MQ_hd_var_size (add_queue_message, | 482 | GNUNET_MQ_hd_var_size (add_queue_message, |
488 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, | 483 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, |
489 | struct GNUNET_TRANSPORT_AddQueueMessage, | 484 | struct GNUNET_TRANSPORT_AddQueueMessage, |
490 | NULL), | 485 | NULL), |
491 | //GNUNET_MQ_hd_fixed_size (del_queue_message, | 486 | //GNUNET_MQ_hd_fixed_size (del_queue_message, |
492 | // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, | 487 | // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, |
493 | // struct GNUNET_TRANSPORT_DelQueueMessage, | 488 | // struct GNUNET_TRANSPORT_DelQueueMessage, |
@@ -506,12 +501,10 @@ transport_communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunica | |||
506 | tc_h, | 501 | tc_h, |
507 | mh); | 502 | mh); |
508 | if (NULL == h) | 503 | if (NULL == h) |
509 | LOG (GNUNET_ERROR_TYPE_ERROR, | 504 | LOG (GNUNET_ERROR_TYPE_ERROR, "Failed starting service!\n"); |
510 | "Failed starting service!\n"); | ||
511 | else | 505 | else |
512 | { | 506 | { |
513 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 507 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Started service\n"); |
514 | "Started service\n"); | ||
515 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_service, h); | 508 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_service, h); |
516 | } | 509 | } |
517 | } | 510 | } |
@@ -527,16 +520,14 @@ shutdown_communicator (void *cls) | |||
527 | { | 520 | { |
528 | struct GNUNET_OS_Process *proc = cls; | 521 | struct GNUNET_OS_Process *proc = cls; |
529 | 522 | ||
530 | if (GNUNET_OK != GNUNET_OS_process_kill (proc, | 523 | if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGTERM)) |
531 | SIGTERM)) | ||
532 | { | 524 | { |
533 | LOG (GNUNET_ERROR_TYPE_WARNING, | 525 | LOG (GNUNET_ERROR_TYPE_WARNING, |
534 | "Error shutting down communicator with SIGERM, trying SIGKILL\n"); | 526 | "Error shutting down communicator with SIGERM, trying SIGKILL\n"); |
535 | if (GNUNET_OK != GNUNET_OS_process_kill (proc, | 527 | if (GNUNET_OK != GNUNET_OS_process_kill (proc, SIGKILL)) |
536 | SIGKILL)) | ||
537 | { | 528 | { |
538 | LOG (GNUNET_ERROR_TYPE_ERROR, | 529 | LOG (GNUNET_ERROR_TYPE_ERROR, |
539 | "Error shutting down communicator with SIGERM and SIGKILL\n"); | 530 | "Error shutting down communicator with SIGERM and SIGKILL\n"); |
540 | } | 531 | } |
541 | } | 532 | } |
542 | GNUNET_OS_process_destroy (proc); | 533 | GNUNET_OS_process_destroy (proc); |
@@ -549,30 +540,29 @@ shutdown_communicator (void *cls) | |||
549 | * @param cfgname Name of the communicator | 540 | * @param cfgname Name of the communicator |
550 | */ | 541 | */ |
551 | static void | 542 | static void |
552 | communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | 543 | communicator_start ( |
544 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | ||
553 | { | 545 | { |
554 | char *binary; | 546 | char *binary; |
555 | 547 | ||
556 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 548 | LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n"); |
557 | "communicator_start\n"); | ||
558 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-communicator-unix"); | 549 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-communicator-unix"); |
559 | tc_h->c_proc = | 550 | tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES, |
560 | GNUNET_OS_start_process (GNUNET_YES, | 551 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
561 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 552 | NULL, |
562 | NULL, NULL, NULL, | 553 | NULL, |
563 | binary, | 554 | NULL, |
564 | "./gnunet-communicator-unix", | 555 | binary, |
565 | "-c", | 556 | "./gnunet-communicator-unix", |
566 | tc_h->cfg_filename, | 557 | "-c", |
567 | NULL); | 558 | tc_h->cfg_filename, |
559 | NULL); | ||
568 | if (NULL == tc_h->c_proc) | 560 | if (NULL == tc_h->c_proc) |
569 | { | 561 | { |
570 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 562 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!"); |
571 | "Failed to start communicator!"); | ||
572 | return; | 563 | return; |
573 | } | 564 | } |
574 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 565 | LOG (GNUNET_ERROR_TYPE_DEBUG, "started communicator\n"); |
575 | "started communicator\n"); | ||
576 | GNUNET_free (binary); | 566 | GNUNET_free (binary); |
577 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_communicator, | 567 | /* TODO */ GNUNET_SCHEDULER_add_shutdown (&shutdown_communicator, |
578 | tc_h->c_proc); | 568 | tc_h->c_proc); |
@@ -592,27 +582,30 @@ communicator_start (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | |||
592 | * @return Handle to the communicator duo | 582 | * @return Handle to the communicator duo |
593 | */ | 583 | */ |
594 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 584 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * |
595 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start | 585 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( |
596 | (const char *service_name, | 586 | const char *service_name, |
597 | const char *cfg_filename, | 587 | const char *cfg_filename, |
598 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb, | 588 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback |
599 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, | 589 | communicator_available_cb, |
600 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, | 590 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, |
601 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, | 591 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, |
602 | void *cb_cls) | 592 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, |
593 | void *cb_cls) | ||
603 | { | 594 | { |
604 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; | 595 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; |
605 | 596 | ||
606 | tc_h = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle); | 597 | tc_h = |
598 | GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle); | ||
607 | tc_h->cfg_filename = GNUNET_strdup (cfg_filename); | 599 | tc_h->cfg_filename = GNUNET_strdup (cfg_filename); |
608 | tc_h->cfg = GNUNET_CONFIGURATION_create (); | 600 | tc_h->cfg = GNUNET_CONFIGURATION_create (); |
609 | if ( (GNUNET_SYSERR == | 601 | if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_load (tc_h->cfg, cfg_filename))) |
610 | GNUNET_CONFIGURATION_load (tc_h->cfg, | ||
611 | cfg_filename)) ) | ||
612 | { | 602 | { |
613 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
614 | _("Malformed configuration file `%s', exit ...\n"), | 604 | _ ("Malformed configuration file `%s', exit ...\n"), |
615 | cfg_filename); | 605 | cfg_filename); |
606 | GNUNET_free (tc_h->cfg_filename); | ||
607 | GNUNET_CONFIGURATION_destroy (tc_h->cfg); | ||
608 | GNUNET_free (tc_h); | ||
616 | return NULL; | 609 | return NULL; |
617 | } | 610 | } |
618 | tc_h->communicator_available_cb = communicator_available_cb; | 611 | tc_h->communicator_available_cb = communicator_available_cb; |
@@ -631,10 +624,10 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start | |||
631 | 624 | ||
632 | 625 | ||
633 | void | 626 | void |
634 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue | 627 | GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( |
635 | (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, | 628 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
636 | const struct GNUNET_PeerIdentity *peer_id, | 629 | const struct GNUNET_PeerIdentity *peer_id, |
637 | const char *address) | 630 | const char *address) |
638 | { | 631 | { |
639 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; | 632 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; |
640 | static uint32_t idgen; | 633 | static uint32_t idgen; |
@@ -643,36 +636,33 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue | |||
643 | struct GNUNET_MQ_Envelope *env; | 636 | struct GNUNET_MQ_Envelope *env; |
644 | size_t alen; | 637 | size_t alen; |
645 | 638 | ||
646 | tc_queue = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue); | 639 | tc_queue = |
640 | GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue); | ||
647 | prefix = GNUNET_HELLO_address_to_prefix (address); | 641 | prefix = GNUNET_HELLO_address_to_prefix (address); |
648 | if (NULL == prefix) | 642 | if (NULL == prefix) |
649 | { | 643 | { |
650 | GNUNET_break (0); /* We got an invalid address!? */ | 644 | GNUNET_break (0); /* We got an invalid address!? */ |
645 | GNUNET_free (tc_queue); | ||
651 | return; | 646 | return; |
652 | } | 647 | } |
648 | GNUNET_free (prefix); | ||
653 | alen = strlen (address) + 1; | 649 | alen = strlen (address) + 1; |
654 | env = GNUNET_MQ_msg_extra (msg, | 650 | env = |
655 | alen, | 651 | GNUNET_MQ_msg_extra (msg, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE); |
656 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE); | ||
657 | msg->request_id = htonl (idgen++); | 652 | msg->request_id = htonl (idgen++); |
658 | tc_queue->qid = msg->request_id; | 653 | tc_queue->qid = msg->request_id; |
659 | msg->receiver = *peer_id; | 654 | msg->receiver = *peer_id; |
660 | tc_queue->peer_id = *peer_id; | 655 | tc_queue->peer_id = *peer_id; |
661 | memcpy (&msg[1], | 656 | memcpy (&msg[1], address, alen); |
662 | address, | ||
663 | alen); | ||
664 | if (NULL != tc_h->c_mq) | 657 | if (NULL != tc_h->c_mq) |
665 | { | 658 | { |
666 | GNUNET_MQ_send (tc_h->c_mq, | 659 | GNUNET_MQ_send (tc_h->c_mq, env); |
667 | env); | ||
668 | } | 660 | } |
669 | else | 661 | else |
670 | { | 662 | { |
671 | tc_queue->open_queue_env = env; | 663 | tc_queue->open_queue_env = env; |
672 | } | 664 | } |
673 | GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, | 665 | GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue); |
674 | tc_h->queue_tail, | ||
675 | tc_queue); | ||
676 | } | 666 | } |
677 | 667 | ||
678 | 668 | ||
@@ -684,7 +674,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send | |||
684 | GNUNET_TRANSPORT_TESTING_SuccessStatus cb, | 674 | GNUNET_TRANSPORT_TESTING_SuccessStatus cb, |
685 | void *cb_cls*/) | 675 | void *cb_cls*/) |
686 | { | 676 | { |
687 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t; | 677 | // struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t; |
688 | struct GNUNET_TRANSPORT_SendMessageTo *msg; | 678 | struct GNUNET_TRANSPORT_SendMessageTo *msg; |
689 | struct GNUNET_MQ_Envelope *env; | 679 | struct GNUNET_MQ_Envelope *env; |
690 | 680 | ||
@@ -694,11 +684,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send | |||
694 | msg->qid = htonl (tc_queue->qid); | 684 | msg->qid = htonl (tc_queue->qid); |
695 | msg->mid = tc_queue->mid++; | 685 | msg->mid = tc_queue->mid++; |
696 | msg->receiver = tc_queue->peer_id; | 686 | msg->receiver = tc_queue->peer_id; |
697 | memcpy (&msg[1], | 687 | memcpy (&msg[1], payload, payload_size); |
698 | payload, | 688 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, env); |
699 | payload_size); | 689 | GNUNET_break (0); /* fixme: return value? */ |
700 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, | 690 | return NULL; // tc_t; |
701 | env); | ||
702 | return tc_t; | ||
703 | } | 691 | } |
704 | |||