diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:39:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-10 13:39:52 +0000 |
commit | f777b26daef27327d4ef692cef1612d5d30ae0ea (patch) | |
tree | 61d5085f5bb8679abaa7086c3e73c4e4ec64553f /src | |
parent | 0e20b185f69cff0f1a29dcc902e94ee2f414cf56 (diff) | |
download | gnunet-f777b26daef27327d4ef692cef1612d5d30ae0ea.tar.gz gnunet-f777b26daef27327d4ef692cef1612d5d30ae0ea.zip |
use LOG macro in arm_api.c
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/arm_api.c | 107 |
1 files changed, 49 insertions, 58 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index cc75e46da..f61eea6fd 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "gnunet_server_lib.h" | 32 | #include "gnunet_server_lib.h" |
33 | #include "arm.h" | 33 | #include "arm.h" |
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "arm-api",__VA_ARGS__) | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * Handle for interacting with ARM. | 38 | * Handle for interacting with ARM. |
@@ -109,8 +110,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
109 | { | 110 | { |
110 | #if DEBUG_ARM | 111 | #if DEBUG_ARM |
111 | /* Means the other side closed the connection and never confirmed a shutdown */ | 112 | /* Means the other side closed the connection and never confirmed a shutdown */ |
112 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 113 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Service handle shutdown before ACK!\n"); |
113 | "Service handle shutdown before ACK!\n"); | ||
114 | #endif | 114 | #endif |
115 | if (shutdown_ctx->cont != NULL) | 115 | if (shutdown_ctx->cont != NULL) |
116 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); | 116 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); |
@@ -121,7 +121,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
121 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) | 121 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) |
122 | { | 122 | { |
123 | #if DEBUG_ARM | 123 | #if DEBUG_ARM |
124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n"); | 124 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n"); |
125 | #endif | 125 | #endif |
126 | if (shutdown_ctx->cont != NULL) | 126 | if (shutdown_ctx->cont != NULL) |
127 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_NO); | 127 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_NO); |
@@ -137,8 +137,8 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
137 | { | 137 | { |
138 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: | 138 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: |
139 | #if DEBUG_ARM | 139 | #if DEBUG_ARM |
140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 140 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
141 | "Received confirmation for service shutdown.\n"); | 141 | "Received confirmation for service shutdown.\n"); |
142 | #endif | 142 | #endif |
143 | shutdown_ctx->confirmed = GNUNET_YES; | 143 | shutdown_ctx->confirmed = GNUNET_YES; |
144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, | 144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
@@ -146,7 +146,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
146 | break; | 146 | break; |
147 | default: /* Fall through */ | 147 | default: /* Fall through */ |
148 | #if DEBUG_ARM | 148 | #if DEBUG_ARM |
149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown refused!\n"); | 149 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown refused!\n"); |
150 | #endif | 150 | #endif |
151 | if (shutdown_ctx->cont != NULL) | 151 | if (shutdown_ctx->cont != NULL) |
152 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_YES); | 152 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_YES); |
@@ -172,7 +172,7 @@ service_shutdown_cancel (void *cls, | |||
172 | struct ShutdownContext *shutdown_ctx = cls; | 172 | struct ShutdownContext *shutdown_ctx = cls; |
173 | 173 | ||
174 | #if DEBUG_ARM | 174 | #if DEBUG_ARM |
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "service_shutdown_cancel called!\n"); | 175 | LOG (GNUNET_ERROR_TYPE_DEBUG, "service_shutdown_cancel called!\n"); |
176 | #endif | 176 | #endif |
177 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); | 177 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); |
178 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 178 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
@@ -197,8 +197,8 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
197 | 197 | ||
198 | if (size < sizeof (struct GNUNET_MessageHeader)) | 198 | if (size < sizeof (struct GNUNET_MessageHeader)) |
199 | { | 199 | { |
200 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 200 | LOG (GNUNET_ERROR_TYPE_WARNING, |
201 | _("Failed to transmit shutdown request to client.\n")); | 201 | _("Failed to transmit shutdown request to client.\n")); |
202 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); | 202 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); |
203 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 203 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
204 | GNUNET_free (shutdown_ctx); | 204 | GNUNET_free (shutdown_ctx); |
@@ -359,8 +359,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
359 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) | 359 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)) |
360 | { | 360 | { |
361 | #if DEBUG_ARM | 361 | #if DEBUG_ARM |
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 362 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Looks like `%s' is already running.\n", |
363 | "Looks like `%s' is already running.\n", "gnunet-service-arm"); | 363 | "gnunet-service-arm"); |
364 | #endif | 364 | #endif |
365 | /* arm is running! */ | 365 | /* arm is running! */ |
366 | if (pos->callback != NULL) | 366 | if (pos->callback != NULL) |
@@ -369,9 +369,9 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
369 | return; | 369 | return; |
370 | } | 370 | } |
371 | #if DEBUG_ARM | 371 | #if DEBUG_ARM |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 372 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
373 | "Looks like `%s' is not running, will start it.\n", | 373 | "Looks like `%s' is not running, will start it.\n", |
374 | "gnunet-service-arm"); | 374 | "gnunet-service-arm"); |
375 | #endif | 375 | #endif |
376 | if (GNUNET_OK != | 376 | if (GNUNET_OK != |
377 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX", | 377 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX", |
@@ -385,10 +385,9 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", | 385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", |
386 | &binary)) | 386 | &binary)) |
387 | { | 387 | { |
388 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 388 | LOG (GNUNET_ERROR_TYPE_WARNING, |
389 | _ | 389 | _("Configuration failes to specify option `%s' in section `%s'!\n"), |
390 | ("Configuration failes to specify option `%s' in section `%s'!\n"), | 390 | "BINARY", "arm"); |
391 | "BINARY", "arm"); | ||
392 | if (pos->callback != NULL) | 391 | if (pos->callback != NULL) |
393 | pos->callback (pos->cls, GNUNET_SYSERR); | 392 | pos->callback (pos->cls, GNUNET_SYSERR); |
394 | GNUNET_free (pos); | 393 | GNUNET_free (pos); |
@@ -400,10 +399,9 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
400 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", | 399 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", |
401 | &config)) | 400 | &config)) |
402 | { | 401 | { |
403 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 402 | LOG (GNUNET_ERROR_TYPE_WARNING, |
404 | _ | 403 | _("Configuration fails to specify option `%s' in section `%s'!\n"), |
405 | ("Configuration fails to specify option `%s' in section `%s'!\n"), | 404 | "CONFIG", "arm"); |
406 | "CONFIG", "arm"); | ||
407 | if (pos->callback != NULL) | 405 | if (pos->callback != NULL) |
408 | pos->callback (pos->cls, GNUNET_SYSERR); | 406 | pos->callback (pos->cls, GNUNET_SYSERR); |
409 | GNUNET_free (binary); | 407 | GNUNET_free (binary); |
@@ -464,11 +462,11 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
464 | 462 | ||
465 | if (msg == NULL) | 463 | if (msg == NULL) |
466 | { | 464 | { |
467 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 465 | LOG (GNUNET_ERROR_TYPE_WARNING, |
468 | _ | 466 | _ |
469 | ("Error receiving response to `%s' request from ARM for service `%s'\n"), | 467 | ("Error receiving response to `%s' request from ARM for service `%s'\n"), |
470 | (sc->type == GNUNET_MESSAGE_TYPE_ARM_START) ? "START" : "STOP", | 468 | (sc->type == GNUNET_MESSAGE_TYPE_ARM_START) ? "START" : "STOP", |
471 | (const char *) &sc[1]); | 469 | (const char *) &sc[1]); |
472 | GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); | 470 | GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); |
473 | sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg); | 471 | sc->h->client = GNUNET_CLIENT_connect ("arm", sc->h->cfg); |
474 | GNUNET_assert (NULL != sc->h->client); | 472 | GNUNET_assert (NULL != sc->h->client); |
@@ -479,9 +477,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
479 | return; | 477 | return; |
480 | } | 478 | } |
481 | #if DEBUG_ARM | 479 | #if DEBUG_ARM |
482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 480 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
483 | "Received response from ARM for service `%s': %u\n", | 481 | "Received response from ARM for service `%s': %u\n", |
484 | (const char *) &sc[1], ntohs (msg->type)); | 482 | (const char *) &sc[1], ntohs (msg->type)); |
485 | #endif | 483 | #endif |
486 | switch (ntohs (msg->type)) | 484 | switch (ntohs (msg->type)) |
487 | { | 485 | { |
@@ -533,11 +531,11 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
533 | return; | 531 | return; |
534 | } | 532 | } |
535 | #if DEBUG_ARM | 533 | #if DEBUG_ARM |
536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 534 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
537 | (type == | 535 | (type == |
538 | GNUNET_MESSAGE_TYPE_ARM_START) ? | 536 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
539 | _("Requesting start of service `%s'.\n") : | 537 | _("Requesting start of service `%s'.\n") : |
540 | _("Requesting termination of service `%s'.\n"), service_name); | 538 | _("Requesting termination of service `%s'.\n"), service_name); |
541 | #endif | 539 | #endif |
542 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); | 540 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); |
543 | sctx->h = h; | 541 | sctx->h = h; |
@@ -556,15 +554,12 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
556 | (sctx->timeout), GNUNET_YES, | 554 | (sctx->timeout), GNUNET_YES, |
557 | &handle_response, sctx)) | 555 | &handle_response, sctx)) |
558 | { | 556 | { |
559 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 557 | LOG (GNUNET_ERROR_TYPE_WARNING, |
560 | (type == | 558 | (type == |
561 | GNUNET_MESSAGE_TYPE_ARM_START) ? | 559 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
562 | _ | 560 | _("Error while trying to transmit request to start `%s' to ARM\n") : |
563 | ("Error while trying to transmit request to start `%s' to ARM\n") | 561 | _("Error while trying to transmit request to stop `%s' to ARM\n"), |
564 | : | 562 | (const char *) &service_name); |
565 | _ | ||
566 | ("Error while trying to transmit request to stop `%s' to ARM\n"), | ||
567 | (const char *) &service_name); | ||
568 | if (cb != NULL) | 563 | if (cb != NULL) |
569 | cb (cb_cls, GNUNET_SYSERR); | 564 | cb (cb_cls, GNUNET_SYSERR); |
570 | GNUNET_free (sctx); | 565 | GNUNET_free (sctx); |
@@ -594,13 +589,10 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
594 | size_t slen; | 589 | size_t slen; |
595 | 590 | ||
596 | #if DEBUG_ARM | 591 | #if DEBUG_ARM |
597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 592 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
598 | _("Asked to start service `%s' within %llu ms\n"), service_name, | 593 | _("Asked to start service `%s' within %llu ms\n"), service_name, |
599 | (unsigned long long) timeout.rel_value); | 594 | (unsigned long long) timeout.rel_value); |
600 | #endif | 595 | #endif |
601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
602 | _("Asked to start service `%s' within %llu ms\n"), service_name, | ||
603 | (unsigned long long) timeout.rel_value); | ||
604 | if (0 == strcasecmp ("arm", service_name)) | 596 | if (0 == strcasecmp ("arm", service_name)) |
605 | { | 597 | { |
606 | slen = strlen ("arm") + 1; | 598 | slen = strlen ("arm") + 1; |
@@ -619,17 +611,17 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
619 | client = GNUNET_CLIENT_connect ("arm", h->cfg); | 611 | client = GNUNET_CLIENT_connect ("arm", h->cfg); |
620 | if (client == NULL) | 612 | if (client == NULL) |
621 | { | 613 | { |
622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 614 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
623 | "arm_api, GNUNET_CLIENT_connect returned NULL\n"); | 615 | "arm_api, GNUNET_CLIENT_connect returned NULL\n"); |
624 | cb (cb_cls, GNUNET_SYSERR); | 616 | cb (cb_cls, GNUNET_SYSERR); |
625 | return; | 617 | return; |
626 | } | 618 | } |
627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 619 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
628 | "arm_api, GNUNET_CLIENT_connect returned non-NULL\n"); | 620 | "arm_api, GNUNET_CLIENT_connect returned non-NULL\n"); |
629 | GNUNET_CLIENT_ignore_shutdown (client, GNUNET_YES); | 621 | GNUNET_CLIENT_ignore_shutdown (client, GNUNET_YES); |
630 | h->client = client; | 622 | h->client = client; |
631 | } | 623 | } |
632 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "arm_api, h->client non-NULL\n"); | 624 | LOG (GNUNET_ERROR_TYPE_DEBUG, "arm_api, h->client non-NULL\n"); |
633 | change_service (h, service_name, timeout, cb, cb_cls, | 625 | change_service (h, service_name, timeout, cb, cb_cls, |
634 | GNUNET_MESSAGE_TYPE_ARM_START); | 626 | GNUNET_MESSAGE_TYPE_ARM_START); |
635 | } | 627 | } |
@@ -671,9 +663,8 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
671 | struct ARM_ShutdownContext *arm_shutdown_ctx; | 663 | struct ARM_ShutdownContext *arm_shutdown_ctx; |
672 | struct GNUNET_CLIENT_Connection *client; | 664 | struct GNUNET_CLIENT_Connection *client; |
673 | 665 | ||
674 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 666 | LOG (GNUNET_ERROR_TYPE_INFO, _("Stopping service `%s' within %llu ms\n"), |
675 | _("Stopping service `%s' within %llu ms\n"), service_name, | 667 | service_name, (unsigned long long) timeout.rel_value); |
676 | (unsigned long long) timeout.rel_value); | ||
677 | if (h->client == NULL) | 668 | if (h->client == NULL) |
678 | { | 669 | { |
679 | client = GNUNET_CLIENT_connect ("arm", h->cfg); | 670 | client = GNUNET_CLIENT_connect ("arm", h->cfg); |