diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-11 12:44:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-11 12:44:50 +0000 |
commit | b339446660675ff6c80018827128f9638d79de8f (patch) | |
tree | 894c35fc91f5a6cfa829d8f6edda5bf1ea2e5f1b /src | |
parent | ae2f377aab457ebc51fe2873e11dd86a5abebad6 (diff) | |
download | gnunet-b339446660675ff6c80018827128f9638d79de8f.tar.gz gnunet-b339446660675ff6c80018827128f9638d79de8f.zip |
fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/arm_api.c | 30 | ||||
-rw-r--r-- | src/arm/gnunet-service-manager.c | 127 | ||||
-rw-r--r-- | src/arm/test_arm_api_data.conf | 2 | ||||
-rw-r--r-- | src/arm/test_gnunet_service_manager.c | 20 |
4 files changed, 126 insertions, 53 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 9485f8692..26ed590a2 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -81,16 +81,10 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
81 | const char *service) | 81 | const char *service) |
82 | { | 82 | { |
83 | struct GNUNET_ARM_Handle *ret; | 83 | struct GNUNET_ARM_Handle *ret; |
84 | struct GNUNET_CLIENT_Connection *client; | ||
85 | 84 | ||
86 | client = GNUNET_CLIENT_connect (sched, "arm", cfg); | ||
87 | if (client == NULL) | ||
88 | return NULL; | ||
89 | GNUNET_CLIENT_ignore_shutdown (client, GNUNET_YES); | ||
90 | ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); | 85 | ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); |
91 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); | 86 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); |
92 | ret->sched = sched; | 87 | ret->sched = sched; |
93 | ret->client = client; | ||
94 | return ret; | 88 | return ret; |
95 | } | 89 | } |
96 | 90 | ||
@@ -412,6 +406,7 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
412 | GNUNET_ARM_Callback cb, void *cb_cls) | 406 | GNUNET_ARM_Callback cb, void *cb_cls) |
413 | { | 407 | { |
414 | struct RequestContext *sctx; | 408 | struct RequestContext *sctx; |
409 | struct GNUNET_CLIENT_Connection *client; | ||
415 | size_t slen; | 410 | size_t slen; |
416 | #if DEBUG_ARM | 411 | #if DEBUG_ARM |
417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 412 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -432,6 +427,17 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
432 | h->cfg, timeout, &arm_service_report, sctx); | 427 | h->cfg, timeout, &arm_service_report, sctx); |
433 | return; | 428 | return; |
434 | } | 429 | } |
430 | if (h->client == NULL) | ||
431 | { | ||
432 | client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); | ||
433 | if (client == NULL) | ||
434 | { | ||
435 | cb (cb_cls, GNUNET_SYSERR); | ||
436 | return; | ||
437 | } | ||
438 | GNUNET_CLIENT_ignore_shutdown (client, GNUNET_YES); | ||
439 | h->client = client; | ||
440 | } | ||
435 | change_service (h, service_name, timeout, cb, cb_cls, GNUNET_MESSAGE_TYPE_ARM_START); | 441 | change_service (h, service_name, timeout, cb, cb_cls, GNUNET_MESSAGE_TYPE_ARM_START); |
436 | } | 442 | } |
437 | 443 | ||
@@ -471,12 +477,24 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, | |||
471 | GNUNET_ARM_Callback cb, void *cb_cls) | 477 | GNUNET_ARM_Callback cb, void *cb_cls) |
472 | { | 478 | { |
473 | struct ARM_ShutdownContext *arm_shutdown_ctx; | 479 | struct ARM_ShutdownContext *arm_shutdown_ctx; |
480 | struct GNUNET_CLIENT_Connection *client; | ||
474 | 481 | ||
475 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 482 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
476 | _("Stopping service `%s' within %llu ms\n"), service_name, | 483 | _("Stopping service `%s' within %llu ms\n"), service_name, |
477 | (unsigned long long) timeout.value); | 484 | (unsigned long long) timeout.value); |
478 | if (0 == strcasecmp ("arm", service_name)) | 485 | if (0 == strcasecmp ("arm", service_name)) |
479 | { | 486 | { |
487 | if (h->client == NULL) | ||
488 | { | ||
489 | client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); | ||
490 | if (client == NULL) | ||
491 | { | ||
492 | cb (cb_cls, GNUNET_SYSERR); | ||
493 | return; | ||
494 | } | ||
495 | GNUNET_CLIENT_ignore_shutdown (client, GNUNET_YES); | ||
496 | h->client = client; | ||
497 | } | ||
480 | arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); | 498 | arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); |
481 | arm_shutdown_ctx->cb = cb; | 499 | arm_shutdown_ctx->cb = cb; |
482 | arm_shutdown_ctx->cb_cls = cb_cls; | 500 | arm_shutdown_ctx->cb_cls = cb_cls; |
diff --git a/src/arm/gnunet-service-manager.c b/src/arm/gnunet-service-manager.c index a632fea49..8eb3847c4 100644 --- a/src/arm/gnunet-service-manager.c +++ b/src/arm/gnunet-service-manager.c | |||
@@ -192,11 +192,15 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, int reason) | |||
192 | if ( (fc->clientReceivingTask != GNUNET_SCHEDULER_NO_TASK) || | 192 | if ( (fc->clientReceivingTask != GNUNET_SCHEDULER_NO_TASK) || |
193 | (fc->serviceReceivingTask != GNUNET_SCHEDULER_NO_TASK) ) | 193 | (fc->serviceReceivingTask != GNUNET_SCHEDULER_NO_TASK) ) |
194 | return; | 194 | return; |
195 | if (GNUNET_SYSERR == | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
196 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) | 196 | "Closing forwarding connection (done with both directions)\n"); |
197 | if ( (NULL != fc->armClientSocket) && | ||
198 | (GNUNET_SYSERR == | ||
199 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) | ||
197 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "close"); | 200 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "close"); |
198 | if (GNUNET_SYSERR == | 201 | if ( (NULL != fc->armServiceSocket) && |
199 | GNUNET_NETWORK_socket_close (fc->armServiceSocket)) | 202 | (GNUNET_SYSERR == |
203 | GNUNET_NETWORK_socket_close (fc->armServiceSocket)) ) | ||
200 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "close"); | 204 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "close"); |
201 | GNUNET_free (fc->listen_info->serviceName); | 205 | GNUNET_free (fc->listen_info->serviceName); |
202 | GNUNET_free (fc->listen_info->service_addr); | 206 | GNUNET_free (fc->listen_info->service_addr); |
@@ -240,6 +244,9 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
240 | GNUNET_NETWORK_socket_send (fc->armClientSocket, | 244 | GNUNET_NETWORK_socket_send (fc->armClientSocket, |
241 | fc->serviceBufferPos, | 245 | fc->serviceBufferPos, |
242 | fc->serviceBufferDataLength); | 246 | fc->serviceBufferDataLength); |
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
248 | "Forwarded %d bytes to client\n", | ||
249 | numberOfBytesSent); | ||
243 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) | 250 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) |
244 | { | 251 | { |
245 | /* Error occured or connection closed by client */ | 252 | /* Error occured or connection closed by client */ |
@@ -300,6 +307,9 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
300 | GNUNET_NETWORK_socket_recv (fc->armServiceSocket, | 307 | GNUNET_NETWORK_socket_recv (fc->armServiceSocket, |
301 | fc->serviceBuffer, BUFFER_SIZE); | 308 | fc->serviceBuffer, BUFFER_SIZE); |
302 | 309 | ||
310 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
311 | "Received %d bytes for client\n", | ||
312 | fc->serviceBufferDataLength); | ||
303 | if (fc->serviceBufferDataLength <= 0) | 313 | if (fc->serviceBufferDataLength <= 0) |
304 | { | 314 | { |
305 | /* The service has closed the connection or an error occured */ | 315 | /* The service has closed the connection or an error occured */ |
@@ -314,7 +324,6 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
314 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
315 | _("Error receiving from service: %s\n"), | 325 | _("Error receiving from service: %s\n"), |
316 | STRERROR (errno)); | 326 | STRERROR (errno)); |
317 | abort (); | ||
318 | } | 327 | } |
319 | closeClientAndServiceSockets (fc, REASON_SERVICE); | 328 | closeClientAndServiceSockets (fc, REASON_SERVICE); |
320 | return; | 329 | return; |
@@ -357,6 +366,9 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
357 | GNUNET_NETWORK_socket_send (fc->armServiceSocket, | 366 | GNUNET_NETWORK_socket_send (fc->armServiceSocket, |
358 | fc->clientBufferPos, | 367 | fc->clientBufferPos, |
359 | fc->clientBufferDataLength); | 368 | fc->clientBufferDataLength); |
369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
370 | "Forwarded %d bytes to service\n", | ||
371 | numberOfBytesSent); | ||
360 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) | 372 | if ((numberOfBytesSent == GNUNET_SYSERR) || (numberOfBytesSent == 0)) |
361 | { | 373 | { |
362 | /* Error occured or connection closed by service */ | 374 | /* Error occured or connection closed by service */ |
@@ -419,7 +431,9 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
419 | fc->clientBufferDataLength = | 431 | fc->clientBufferDataLength = |
420 | GNUNET_NETWORK_socket_recv (fc->armClientSocket, | 432 | GNUNET_NETWORK_socket_recv (fc->armClientSocket, |
421 | fc->clientBuffer, BUFFER_SIZE); | 433 | fc->clientBuffer, BUFFER_SIZE); |
422 | 434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
435 | "Received %d bytes for service\n", | ||
436 | fc->clientBufferDataLength); | ||
423 | if (fc->clientBufferDataLength <= 0) | 437 | if (fc->clientBufferDataLength <= 0) |
424 | { | 438 | { |
425 | /* The client has closed the connection or and error occured */ | 439 | /* The client has closed the connection or and error occured */ |
@@ -443,15 +457,9 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
443 | } | 457 | } |
444 | 458 | ||
445 | 459 | ||
446 | /** | ||
447 | * ARM connects to the just created service, | ||
448 | * starts the processes for relaying messages between the client and the service | ||
449 | * | ||
450 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | ||
451 | * @param tc context | ||
452 | */ | ||
453 | static void | 460 | static void |
454 | connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 461 | start_forwarding (void *cls, |
462 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
455 | { | 463 | { |
456 | struct ForwardedConnection *fc = cls; | 464 | struct ForwardedConnection *fc = cls; |
457 | 465 | ||
@@ -465,18 +473,8 @@ connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
465 | (REASON_CLIENT & REASON_SERVICE)); | 473 | (REASON_CLIENT & REASON_SERVICE)); |
466 | return; | 474 | return; |
467 | } | 475 | } |
468 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
469 | { | 477 | _("Connection to service to start forwarding\n")); |
470 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
471 | _("Unable to start service `%s': shutdown\n"), | ||
472 | fc->listen_info->serviceName); | ||
473 | closeClientAndServiceSockets (fc, | ||
474 | (REASON_CLIENT & REASON_SERVICE)); | ||
475 | return; | ||
476 | } | ||
477 | GNUNET_break (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
478 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' started\n"), | ||
479 | fc->listen_info->serviceName); | ||
480 | fc->armServiceSocket = | 478 | fc->armServiceSocket = |
481 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, | 479 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, |
482 | SOCK_STREAM, 0); | 480 | SOCK_STREAM, 0); |
@@ -516,6 +514,50 @@ connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
516 | } | 514 | } |
517 | 515 | ||
518 | 516 | ||
517 | /** | ||
518 | * ARM connects to the just created service, | ||
519 | * starts the processes for relaying messages between the client and the service | ||
520 | * | ||
521 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | ||
522 | * @param tc context | ||
523 | */ | ||
524 | static void | ||
525 | connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
526 | { | ||
527 | struct ForwardedConnection *fc = cls; | ||
528 | |||
529 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | ||
530 | { | ||
531 | /* Service is not up. Unable to proceed */ | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | _("Unable to start service `%s': timeout\n"), | ||
534 | fc->listen_info->serviceName); | ||
535 | closeClientAndServiceSockets (fc, | ||
536 | (REASON_CLIENT & REASON_SERVICE)); | ||
537 | return; | ||
538 | } | ||
539 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
540 | { | ||
541 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
542 | _("Unable to start service `%s': shutdown\n"), | ||
543 | fc->listen_info->serviceName); | ||
544 | closeClientAndServiceSockets (fc, | ||
545 | (REASON_CLIENT & REASON_SERVICE)); | ||
546 | return; | ||
547 | } | ||
548 | GNUNET_break (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
549 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' started\n"), | ||
550 | fc->listen_info->serviceName); | ||
551 | |||
552 | GNUNET_CLIENT_service_test (scheduler, | ||
553 | fc->listen_info->serviceName, | ||
554 | cfg, | ||
555 | TIMEOUT, | ||
556 | &start_forwarding, | ||
557 | fc); | ||
558 | } | ||
559 | |||
560 | |||
519 | void stop_listening (const char *serviceName) | 561 | void stop_listening (const char *serviceName) |
520 | { | 562 | { |
521 | struct ServiceListeningInfo *pos; | 563 | struct ServiceListeningInfo *pos; |
@@ -610,34 +652,39 @@ createListeningSocket (struct sockaddr *sa, | |||
610 | socklen_t addr_len, | 652 | socklen_t addr_len, |
611 | const char *serviceName) | 653 | const char *serviceName) |
612 | { | 654 | { |
613 | struct GNUNET_NETWORK_Handle *socket; | 655 | const static int on = 1; |
656 | struct GNUNET_NETWORK_Handle *sock; | ||
614 | struct ServiceListeningInfo *serviceListeningInfo; | 657 | struct ServiceListeningInfo *serviceListeningInfo; |
615 | 658 | ||
616 | switch (sa->sa_family) | 659 | switch (sa->sa_family) |
617 | { | 660 | { |
618 | case AF_INET: | 661 | case AF_INET: |
619 | socket = GNUNET_NETWORK_socket_create (PF_INET, SOCK_STREAM, 0); | 662 | sock = GNUNET_NETWORK_socket_create (PF_INET, SOCK_STREAM, 0); |
620 | fprintf (stderr, "IPv4 listening at %p\n", | 663 | fprintf (stderr, "IPv4 listening at %p\n", |
621 | socket); | 664 | sock); |
622 | break; | 665 | break; |
623 | case AF_INET6: | 666 | case AF_INET6: |
624 | socket = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | 667 | sock = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
625 | fprintf (stderr, "IPv6 listening at %p\n", | 668 | fprintf (stderr, "IPv6 listening at %p\n", |
626 | socket); | 669 | sock); |
627 | break; | 670 | break; |
628 | default: | 671 | default: |
629 | socket = NULL; | 672 | sock = NULL; |
630 | break; | 673 | break; |
631 | } | 674 | } |
632 | if (NULL == socket) | 675 | if (NULL == sock) |
633 | { | 676 | { |
634 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 677 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
635 | "Unable to create socket for service %s", serviceName); | 678 | "Unable to create socket for service %s", serviceName); |
636 | GNUNET_free (sa); | 679 | GNUNET_free (sa); |
637 | return; | 680 | return; |
638 | } | 681 | } |
682 | if (GNUNET_NETWORK_socket_setsockopt | ||
683 | (sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | ||
684 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
685 | "setsockopt"); | ||
639 | if (GNUNET_NETWORK_socket_bind | 686 | if (GNUNET_NETWORK_socket_bind |
640 | (socket, (const struct sockaddr *) sa, addr_len) != GNUNET_OK) | 687 | (sock, (const struct sockaddr *) sa, addr_len) != GNUNET_OK) |
641 | { | 688 | { |
642 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 689 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
643 | _("Unable to bind listening socket for service `%s'\n"), | 690 | _("Unable to bind listening socket for service `%s'\n"), |
@@ -645,12 +692,12 @@ createListeningSocket (struct sockaddr *sa, | |||
645 | GNUNET_free (sa); | 692 | GNUNET_free (sa); |
646 | return; | 693 | return; |
647 | } | 694 | } |
648 | if (GNUNET_NETWORK_socket_listen (socket, 5) != GNUNET_OK) | 695 | if (GNUNET_NETWORK_socket_listen (sock, 5) != GNUNET_OK) |
649 | { | 696 | { |
650 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 697 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
651 | _("Error listening socket for service `%s'\n"), | 698 | _("Error listening socket for service `%s'\n"), |
652 | serviceName); | 699 | serviceName); |
653 | GNUNET_NETWORK_socket_close (socket); | 700 | GNUNET_NETWORK_socket_close (sock); |
654 | GNUNET_free (sa); | 701 | GNUNET_free (sa); |
655 | return; | 702 | return; |
656 | } | 703 | } |
@@ -658,10 +705,10 @@ createListeningSocket (struct sockaddr *sa, | |||
658 | serviceListeningInfo->serviceName = GNUNET_strdup (serviceName); | 705 | serviceListeningInfo->serviceName = GNUNET_strdup (serviceName); |
659 | serviceListeningInfo->service_addr = sa; | 706 | serviceListeningInfo->service_addr = sa; |
660 | serviceListeningInfo->service_addr_len = addr_len; | 707 | serviceListeningInfo->service_addr_len = addr_len; |
661 | serviceListeningInfo->listeningSocket = socket; | 708 | serviceListeningInfo->listeningSocket = sock; |
662 | serviceListeningInfo->acceptTask = | 709 | serviceListeningInfo->acceptTask = |
663 | GNUNET_SCHEDULER_add_read_net (scheduler, | 710 | GNUNET_SCHEDULER_add_read_net (scheduler, |
664 | GNUNET_TIME_UNIT_FOREVER_REL, socket, | 711 | GNUNET_TIME_UNIT_FOREVER_REL, sock, |
665 | &acceptConnection, | 712 | &acceptConnection, |
666 | serviceListeningInfo); | 713 | serviceListeningInfo); |
667 | GNUNET_CONTAINER_DLL_insert (serviceListeningInfoList_head, | 714 | GNUNET_CONTAINER_DLL_insert (serviceListeningInfoList_head, |
@@ -690,8 +737,8 @@ checkPortNumberCB (void *cls, | |||
690 | int ret; | 737 | int ret; |
691 | unsigned int i; | 738 | unsigned int i; |
692 | 739 | ||
693 | if ( (strcmp (section, "arm") == 0) || | 740 | if ( (strcasecmp (section, "arm") == 0) || |
694 | (strcmp (option, "PORT") != 0) || | 741 | (strcasecmp (option, "PORT") != 0) || |
695 | (isInDefaultList (section) == GNUNET_YES) ) | 742 | (isInDefaultList (section) == GNUNET_YES) ) |
696 | return; | 743 | return; |
697 | if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, | 744 | if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, |
diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf index 17a8ac613..adfab9b8f 100644 --- a/src/arm/test_arm_api_data.conf +++ b/src/arm/test_arm_api_data.conf | |||
@@ -6,7 +6,7 @@ DEFAULTCONFIG = test_arm_api_data.conf | |||
6 | PORT = 23354 | 6 | PORT = 23354 |
7 | DEFAULTSERVICES = | 7 | DEFAULTSERVICES = |
8 | BINARY = gnunet-service-arm | 8 | BINARY = gnunet-service-arm |
9 | OPTIONS = -L ERROR | 9 | OPTIONS = -L DEBUG |
10 | #DEBUG = YES | 10 | #DEBUG = YES |
11 | 11 | ||
12 | [resolver] | 12 | [resolver] |
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index d0c29ded5..9878dca17 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c | |||
@@ -38,19 +38,28 @@ | |||
38 | 38 | ||
39 | #define START_ARM GNUNET_YES | 39 | #define START_ARM GNUNET_YES |
40 | 40 | ||
41 | #define VERBOSE GNUNET_YES | ||
42 | |||
41 | static int ret = 1; | 43 | static int ret = 1; |
42 | 44 | ||
43 | static struct GNUNET_SCHEDULER_Handle *sched; | 45 | static struct GNUNET_SCHEDULER_Handle *sched; |
44 | 46 | ||
45 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 47 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
46 | 48 | ||
49 | #if START_ARM | ||
47 | static struct GNUNET_ARM_Handle *arm; | 50 | static struct GNUNET_ARM_Handle *arm; |
51 | #endif | ||
48 | 52 | ||
49 | static void | 53 | static void |
50 | arm_stopped (void *cls, int success) | 54 | arm_stopped (void *cls, int success) |
51 | { | 55 | { |
52 | if (success != GNUNET_OK) | 56 | if (success != GNUNET_NO) |
53 | ret = 4; | 57 | { |
58 | GNUNET_break (0); | ||
59 | ret = 4; | ||
60 | } | ||
61 | GNUNET_ARM_disconnect (arm); | ||
62 | arm = NULL; | ||
54 | } | 63 | } |
55 | 64 | ||
56 | static void | 65 | static void |
@@ -62,8 +71,8 @@ hostNameResolveCB(void *cls, | |||
62 | return; | 71 | return; |
63 | if (NULL == addr) | 72 | if (NULL == addr) |
64 | { | 73 | { |
65 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 74 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
66 | "Name not resolved!\n"); | 75 | "Name not resolved!\n"); |
67 | #if START_ARM | 76 | #if START_ARM |
68 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); | 77 | GNUNET_ARM_stop_service (arm, "arm", TIMEOUT, &arm_stopped, NULL); |
69 | #endif | 78 | #endif |
@@ -77,7 +86,6 @@ hostNameResolveCB(void *cls, | |||
77 | } | 86 | } |
78 | 87 | ||
79 | 88 | ||
80 | |||
81 | static void | 89 | static void |
82 | arm_notify (void *cls, int success) | 90 | arm_notify (void *cls, int success) |
83 | { | 91 | { |
@@ -113,8 +121,8 @@ run(void *cls, | |||
113 | { | 121 | { |
114 | cfg = c; | 122 | cfg = c; |
115 | sched = s; | 123 | sched = s; |
116 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | ||
117 | #if START_ARM | 124 | #if START_ARM |
125 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | ||
118 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); | 126 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); |
119 | #else | 127 | #else |
120 | arm_notify (NULL, GNUNET_YES); | 128 | arm_notify (NULL, GNUNET_YES); |