diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-20 21:51:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-20 21:51:44 +0000 |
commit | 1ad53c2941cf815064328f6a55f51bea291e7bed (patch) | |
tree | 3868af7af74aa6caef283e24aeb450327624a685 /src/arm | |
parent | 5f87229da63274cacd6711cce3ad340dfc468569 (diff) | |
download | gnunet-1ad53c2941cf815064328f6a55f51bea291e7bed.tar.gz gnunet-1ad53c2941cf815064328f6a55f51bea291e7bed.zip |
-indenting and doxygen
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/arm_api.c | 219 |
1 files changed, 149 insertions, 70 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 5fb2a811a..a0157ead6 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010, 2012, 2013 GNUnet e.V. | 3 | Copyright (C) 2009, 2010, 2012, 2013, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -40,7 +40,7 @@ struct GNUNET_ARM_Handle | |||
40 | /** | 40 | /** |
41 | * Our control connection to the ARM service. | 41 | * Our control connection to the ARM service. |
42 | */ | 42 | */ |
43 | struct GNUNET_CLIENT_Connection *client; | 43 | struct GNUNET_MQ_Handle *mq; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * The configuration that we are using. | 46 | * The configuration that we are using. |
@@ -154,7 +154,7 @@ struct ARMControlMessage | |||
154 | GNUNET_ARM_ServiceListCallback list_cont; | 154 | GNUNET_ARM_ServiceListCallback list_cont; |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Closure for @e result_cont' or @e list_cont'. | 157 | * Closure for @e result_cont or @e list_cont. |
158 | */ | 158 | */ |
159 | void *cont_cls; | 159 | void *cont_cls; |
160 | 160 | ||
@@ -166,7 +166,7 @@ struct ARMControlMessage | |||
166 | /** | 166 | /** |
167 | * Task to run when request times out. | 167 | * Task to run when request times out. |
168 | */ | 168 | */ |
169 | struct GNUNET_SCHEDULER_Task * timeout_task_id; | 169 | struct GNUNET_SCHEDULER_Task *timeout_task_id; |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Flags for passing std descriptors to ARM (when starting ARM). | 172 | * Flags for passing std descriptors to ARM (when starting ARM). |
@@ -198,13 +198,14 @@ reconnect_arm (struct GNUNET_ARM_Handle *h); | |||
198 | * @param ignore_currently_down transmit message even if not initialized? | 198 | * @param ignore_currently_down transmit message even if not initialized? |
199 | */ | 199 | */ |
200 | static void | 200 | static void |
201 | trigger_next_request (struct GNUNET_ARM_Handle *h, int ignore_currently_down); | 201 | trigger_next_request (struct GNUNET_ARM_Handle *h, |
202 | int ignore_currently_down); | ||
202 | 203 | ||
203 | 204 | ||
204 | /** | 205 | /** |
205 | * Task scheduled to try to re-connect to arm. | 206 | * Task scheduled to try to re-connect to arm. |
206 | * | 207 | * |
207 | * @param cls the 'struct GNUNET_ARM_Handle' | 208 | * @param cls the `struct GNUNET_ARM_Handle` |
208 | */ | 209 | */ |
209 | static void | 210 | static void |
210 | reconnect_arm_task (void *cls) | 211 | reconnect_arm_task (void *cls) |
@@ -212,7 +213,8 @@ reconnect_arm_task (void *cls) | |||
212 | struct GNUNET_ARM_Handle *h = cls; | 213 | struct GNUNET_ARM_Handle *h = cls; |
213 | 214 | ||
214 | h->reconnect_task = NULL; | 215 | h->reconnect_task = NULL; |
215 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting to ARM service after delay\n"); | 216 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
217 | "Connecting to ARM service after delay\n"); | ||
216 | reconnect_arm (h); | 218 | reconnect_arm (h); |
217 | } | 219 | } |
218 | 220 | ||
@@ -250,7 +252,8 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h) | |||
250 | */ | 252 | */ |
251 | h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff); | 253 | h->retry_backoff = GNUNET_TIME_STD_BACKOFF (h->retry_backoff); |
252 | if (NULL != h->conn_status) | 254 | if (NULL != h->conn_status) |
253 | h->conn_status (h->conn_status_cls, GNUNET_NO); | 255 | h->conn_status (h->conn_status_cls, |
256 | GNUNET_NO); | ||
254 | } | 257 | } |
255 | 258 | ||
256 | 259 | ||
@@ -262,10 +265,12 @@ reconnect_arm_later (struct GNUNET_ARM_Handle *h) | |||
262 | * @return NULL if not found | 265 | * @return NULL if not found |
263 | */ | 266 | */ |
264 | static struct ARMControlMessage * | 267 | static struct ARMControlMessage * |
265 | find_cm_by_id (struct GNUNET_ARM_Handle *h, uint64_t id) | 268 | find_cm_by_id (struct GNUNET_ARM_Handle *h, |
269 | uint64_t id) | ||
266 | { | 270 | { |
267 | struct ARMControlMessage *result; | 271 | struct ARMControlMessage *result; |
268 | for (result = h->control_sent_head; result; result = result->next) | 272 | |
273 | for (result = h->control_sent_head; NULL != result; result = result->next) | ||
269 | if (id == result->msg->request_id) | 274 | if (id == result->msg->request_id) |
270 | return result; | 275 | return result; |
271 | return NULL; | 276 | return NULL; |
@@ -275,11 +280,12 @@ find_cm_by_id (struct GNUNET_ARM_Handle *h, uint64_t id) | |||
275 | /** | 280 | /** |
276 | * Handler for ARM 'termination' reply (failure to receive). | 281 | * Handler for ARM 'termination' reply (failure to receive). |
277 | * | 282 | * |
278 | * @param cls our "struct GNUNET_ARM_Handle" | 283 | * @param cls our `struct GNUNET_ARM_Handle` |
279 | * @param msg expected to be NULL | 284 | * @param msg expected to be NULL |
280 | */ | 285 | */ |
281 | static void | 286 | static void |
282 | arm_termination_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 287 | arm_termination_handler (void *cls, |
288 | const struct GNUNET_MessageHeader *msg) | ||
283 | { | 289 | { |
284 | struct GNUNET_ARM_Handle *h = cls; | 290 | struct GNUNET_ARM_Handle *h = cls; |
285 | struct ARMControlMessage *cm; | 291 | struct ARMControlMessage *cm; |
@@ -287,7 +293,9 @@ arm_termination_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
287 | if (NULL != msg) | 293 | if (NULL != msg) |
288 | { | 294 | { |
289 | GNUNET_break (0); | 295 | GNUNET_break (0); |
290 | GNUNET_CLIENT_receive (h->client, &arm_termination_handler, h, | 296 | GNUNET_CLIENT_receive (h->client, |
297 | &arm_termination_handler, | ||
298 | h, | ||
291 | GNUNET_TIME_UNIT_FOREVER_REL); | 299 | GNUNET_TIME_UNIT_FOREVER_REL); |
292 | return; | 300 | return; |
293 | } | 301 | } |
@@ -412,7 +420,8 @@ client_notify_handler (void *cls, | |||
412 | GNUNET_assert (NULL != cm->timeout_task_id); | 420 | GNUNET_assert (NULL != cm->timeout_task_id); |
413 | GNUNET_SCHEDULER_cancel (cm->timeout_task_id); | 421 | GNUNET_SCHEDULER_cancel (cm->timeout_task_id); |
414 | GNUNET_CONTAINER_DLL_remove (h->control_sent_head, | 422 | GNUNET_CONTAINER_DLL_remove (h->control_sent_head, |
415 | h->control_sent_tail, cm); | 423 | h->control_sent_tail, |
424 | cm); | ||
416 | if (GNUNET_YES == fail) | 425 | if (GNUNET_YES == fail) |
417 | { | 426 | { |
418 | reconnect_arm_later (h); | 427 | reconnect_arm_later (h); |
@@ -442,11 +451,15 @@ client_notify_handler (void *cls, | |||
442 | GNUNET_free (h->thm); | 451 | GNUNET_free (h->thm); |
443 | } | 452 | } |
444 | h->thm = cm; | 453 | h->thm = cm; |
445 | GNUNET_CLIENT_receive (h->client, &arm_termination_handler, h, | 454 | GNUNET_CLIENT_receive (h->client, |
455 | &arm_termination_handler, | ||
456 | h, | ||
446 | GNUNET_TIME_UNIT_FOREVER_REL); | 457 | GNUNET_TIME_UNIT_FOREVER_REL); |
447 | return; | 458 | return; |
448 | } | 459 | } |
449 | GNUNET_CLIENT_receive (h->client, &client_notify_handler, h, | 460 | GNUNET_CLIENT_receive (h->client, |
461 | &client_notify_handler, | ||
462 | h, | ||
450 | GNUNET_TIME_UNIT_FOREVER_REL); | 463 | GNUNET_TIME_UNIT_FOREVER_REL); |
451 | switch (ntohs (msg->type)) | 464 | switch (ntohs (msg->type)) |
452 | { | 465 | { |
@@ -457,12 +470,16 @@ client_notify_handler (void *cls, | |||
457 | (const char *) &cm->msg[1], ntohs (msg->type)); | 470 | (const char *) &cm->msg[1], ntohs (msg->type)); |
458 | result = (enum GNUNET_ARM_Result) ntohl (res->result); | 471 | result = (enum GNUNET_ARM_Result) ntohl (res->result); |
459 | if (NULL != cm->result_cont) | 472 | if (NULL != cm->result_cont) |
460 | cm->result_cont (cm->cont_cls, GNUNET_ARM_REQUEST_SENT_OK, | 473 | cm->result_cont (cm->cont_cls, |
461 | (const char *) &cm->msg[1], result); | 474 | GNUNET_ARM_REQUEST_SENT_OK, |
475 | (const char *) &cm->msg[1], | ||
476 | result); | ||
462 | break; | 477 | break; |
463 | case GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT: | 478 | case GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT: |
464 | if (NULL != cm->list_cont) | 479 | if (NULL != cm->list_cont) |
465 | cm->list_cont (cm->cont_cls, GNUNET_ARM_REQUEST_SENT_OK, rcount, | 480 | cm->list_cont (cm->cont_cls, |
481 | GNUNET_ARM_REQUEST_SENT_OK, | ||
482 | rcount, | ||
466 | list); | 483 | list); |
467 | GNUNET_free_non_null (list); | 484 | GNUNET_free_non_null (list); |
468 | break; | 485 | break; |
@@ -481,7 +498,9 @@ client_notify_handler (void *cls, | |||
481 | * @return number of bytes written to @a buf | 498 | * @return number of bytes written to @a buf |
482 | */ | 499 | */ |
483 | static size_t | 500 | static size_t |
484 | transmit_arm_message (void *cls, size_t size, void *buf) | 501 | transmit_arm_message (void *cls, |
502 | size_t size, | ||
503 | void *buf) | ||
485 | { | 504 | { |
486 | struct GNUNET_ARM_Handle *h = cls; | 505 | struct GNUNET_ARM_Handle *h = cls; |
487 | struct ARMControlMessage *cm; | 506 | struct ARMControlMessage *cm; |
@@ -534,16 +553,20 @@ transmit_arm_message (void *cls, size_t size, void *buf) | |||
534 | request_id = h->request_id_counter++; | 553 | request_id = h->request_id_counter++; |
535 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 554 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
536 | "Transmitting control message with %u bytes of type %u to arm with id %llu\n", | 555 | "Transmitting control message with %u bytes of type %u to arm with id %llu\n", |
537 | (unsigned int) msize, (unsigned int) ntohs (cm->msg->header.type), request_id); | 556 | (unsigned int) msize, |
557 | (unsigned int) ntohs (cm->msg->header.type), | ||
558 | request_id); | ||
538 | arm_msg->reserved = htonl (0); | 559 | arm_msg->reserved = htonl (0); |
539 | arm_msg->request_id = GNUNET_htonll (request_id); | 560 | arm_msg->request_id = GNUNET_htonll (request_id); |
540 | memcpy (buf, cm->msg, msize); | 561 | memcpy (buf, cm->msg, msize); |
541 | /* Otherwise we won't be able to find it later! */ | 562 | /* Otherwise we won't be able to find it later! */ |
542 | arm_msg->request_id = request_id; | 563 | arm_msg->request_id = request_id; |
543 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | 564 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, |
544 | h->control_pending_tail, cm); | 565 | h->control_pending_tail, |
566 | cm); | ||
545 | GNUNET_CONTAINER_DLL_insert_tail (h->control_sent_head, | 567 | GNUNET_CONTAINER_DLL_insert_tail (h->control_sent_head, |
546 | h->control_sent_tail, cm); | 568 | h->control_sent_tail, |
569 | cm); | ||
547 | /* Don't free msg, keep it around (kind of wasteful, but then we don't | 570 | /* Don't free msg, keep it around (kind of wasteful, but then we don't |
548 | * really have many messages to handle, and it'll be freed when it times | 571 | * really have many messages to handle, and it'll be freed when it times |
549 | * out anyway. | 572 | * out anyway. |
@@ -565,7 +588,8 @@ transmit_arm_message (void *cls, size_t size, void *buf) | |||
565 | * @param ignore_currently_down transmit message even if not initialized? | 588 | * @param ignore_currently_down transmit message even if not initialized? |
566 | */ | 589 | */ |
567 | static void | 590 | static void |
568 | trigger_next_request (struct GNUNET_ARM_Handle *h, int ignore_currently_down) | 591 | trigger_next_request (struct GNUNET_ARM_Handle *h, |
592 | int ignore_currently_down) | ||
569 | { | 593 | { |
570 | uint16_t msize; | 594 | uint16_t msize; |
571 | 595 | ||
@@ -578,7 +602,8 @@ trigger_next_request (struct GNUNET_ARM_Handle *h, int ignore_currently_down) | |||
578 | } | 602 | } |
579 | if (NULL != h->cth) | 603 | if (NULL != h->cth) |
580 | { | 604 | { |
581 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n"); | 605 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
606 | "Request pending, not processing queue\n"); | ||
582 | return; | 607 | return; |
583 | } | 608 | } |
584 | if (NULL != h->control_pending_head) | 609 | if (NULL != h->control_pending_head) |
@@ -591,9 +616,11 @@ trigger_next_request (struct GNUNET_ARM_Handle *h, int ignore_currently_down) | |||
591 | return; /* no pending message */ | 616 | return; /* no pending message */ |
592 | } | 617 | } |
593 | h->cth = | 618 | h->cth = |
594 | GNUNET_CLIENT_notify_transmit_ready (h->client, msize, | 619 | GNUNET_CLIENT_notify_transmit_ready (h->client, |
620 | msize, | ||
595 | GNUNET_TIME_UNIT_FOREVER_REL, | 621 | GNUNET_TIME_UNIT_FOREVER_REL, |
596 | GNUNET_NO, &transmit_arm_message, h); | 622 | GNUNET_NO, |
623 | &transmit_arm_message, h); | ||
597 | } | 624 | } |
598 | 625 | ||
599 | 626 | ||
@@ -601,7 +628,7 @@ trigger_next_request (struct GNUNET_ARM_Handle *h, int ignore_currently_down) | |||
601 | * Connect to arm. | 628 | * Connect to arm. |
602 | * | 629 | * |
603 | * @param h arm handle | 630 | * @param h arm handle |
604 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 631 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
605 | */ | 632 | */ |
606 | static int | 633 | static int |
607 | reconnect_arm (struct GNUNET_ARM_Handle *h) | 634 | reconnect_arm (struct GNUNET_ARM_Handle *h) |
@@ -614,12 +641,14 @@ reconnect_arm (struct GNUNET_ARM_Handle *h) | |||
614 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 641 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
615 | "arm_api, GNUNET_CLIENT_connect returned NULL\n"); | 642 | "arm_api, GNUNET_CLIENT_connect returned NULL\n"); |
616 | if (NULL != h->conn_status) | 643 | if (NULL != h->conn_status) |
617 | h->conn_status (h->conn_status_cls, GNUNET_SYSERR); | 644 | h->conn_status (h->conn_status_cls, |
645 | GNUNET_SYSERR); | ||
618 | return GNUNET_SYSERR; | 646 | return GNUNET_SYSERR; |
619 | } | 647 | } |
620 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 648 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
621 | "arm_api, GNUNET_CLIENT_connect returned non-NULL\n"); | 649 | "arm_api, GNUNET_CLIENT_connect returned non-NULL\n"); |
622 | trigger_next_request (h, GNUNET_YES); | 650 | trigger_next_request (h, |
651 | GNUNET_YES); | ||
623 | return GNUNET_OK; | 652 | return GNUNET_OK; |
624 | } | 653 | } |
625 | 654 | ||
@@ -667,7 +696,8 @@ GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h) | |||
667 | { | 696 | { |
668 | struct ARMControlMessage *cm; | 697 | struct ARMControlMessage *cm; |
669 | 698 | ||
670 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from ARM service\n"); | 699 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
700 | "Disconnecting from ARM service\n"); | ||
671 | if (NULL != h->cth) | 701 | if (NULL != h->cth) |
672 | { | 702 | { |
673 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); | 703 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); |
@@ -678,15 +708,19 @@ GNUNET_ARM_disconnect_and_free (struct GNUNET_ARM_Handle *h) | |||
678 | { | 708 | { |
679 | if (NULL != h->control_pending_head) | 709 | if (NULL != h->control_pending_head) |
680 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | 710 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, |
681 | h->control_pending_tail, cm); | 711 | h->control_pending_tail, |
712 | cm); | ||
682 | else | 713 | else |
683 | GNUNET_CONTAINER_DLL_remove (h->control_sent_head, | 714 | GNUNET_CONTAINER_DLL_remove (h->control_sent_head, |
684 | h->control_sent_tail, cm); | 715 | h->control_sent_tail, |
716 | cm); | ||
685 | GNUNET_assert (NULL != cm->timeout_task_id); | 717 | GNUNET_assert (NULL != cm->timeout_task_id); |
686 | GNUNET_SCHEDULER_cancel (cm->timeout_task_id); | 718 | GNUNET_SCHEDULER_cancel (cm->timeout_task_id); |
687 | if (NULL != cm->result_cont) | 719 | if (NULL != cm->result_cont) |
688 | cm->result_cont (cm->cont_cls, GNUNET_ARM_REQUEST_DISCONNECTED, | 720 | cm->result_cont (cm->cont_cls, |
689 | NULL, 0); | 721 | GNUNET_ARM_REQUEST_DISCONNECTED, |
722 | NULL, | ||
723 | 0); | ||
690 | /* FIXME: What about list callback? */ | 724 | /* FIXME: What about list callback? */ |
691 | GNUNET_free_non_null (cm->msg); | 725 | GNUNET_free_non_null (cm->msg); |
692 | GNUNET_free (cm); | 726 | GNUNET_free (cm); |
@@ -726,17 +760,23 @@ control_message_timeout (void *cls) | |||
726 | if ((NULL == arm_msg) || (0 == arm_msg->request_id)) | 760 | if ((NULL == arm_msg) || (0 == arm_msg->request_id)) |
727 | { | 761 | { |
728 | GNUNET_CONTAINER_DLL_remove (cm->h->control_pending_head, | 762 | GNUNET_CONTAINER_DLL_remove (cm->h->control_pending_head, |
729 | cm->h->control_pending_tail, cm); | 763 | cm->h->control_pending_tail, |
764 | cm); | ||
730 | } | 765 | } |
731 | else | 766 | else |
732 | { | 767 | { |
733 | GNUNET_CONTAINER_DLL_remove (cm->h->control_sent_head, | 768 | GNUNET_CONTAINER_DLL_remove (cm->h->control_sent_head, |
734 | cm->h->control_sent_tail, cm); | 769 | cm->h->control_sent_tail, |
770 | cm); | ||
735 | } | 771 | } |
736 | if (NULL != cm->result_cont) | 772 | if (NULL != cm->result_cont) |
737 | cm->result_cont (cm->cont_cls, GNUNET_ARM_REQUEST_TIMEOUT, NULL, 0); | 773 | cm->result_cont (cm->cont_cls, |
774 | GNUNET_ARM_REQUEST_TIMEOUT, | ||
775 | NULL, 0); | ||
738 | else if (NULL != cm->list_cont) | 776 | else if (NULL != cm->list_cont) |
739 | cm->list_cont (cm->cont_cls, GNUNET_ARM_REQUEST_TIMEOUT, 0, NULL); | 777 | cm->list_cont (cm->cont_cls, |
778 | GNUNET_ARM_REQUEST_TIMEOUT, | ||
779 | 0, NULL); | ||
740 | GNUNET_free_non_null (cm->msg); | 780 | GNUNET_free_non_null (cm->msg); |
741 | GNUNET_free (cm); | 781 | GNUNET_free (cm); |
742 | } | 782 | } |
@@ -797,11 +837,17 @@ arm_service_report (void *cls, | |||
797 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 837 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
798 | "Looks like `%s' is not running, will start it.\n", | 838 | "Looks like `%s' is not running, will start it.\n", |
799 | "gnunet-service-arm"); | 839 | "gnunet-service-arm"); |
800 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string ( | 840 | if (GNUNET_OK != |
801 | cm->h->cfg, "arm", "PREFIX", &loprefix)) | 841 | GNUNET_CONFIGURATION_get_value_string (cm->h->cfg, |
842 | "arm", | ||
843 | "PREFIX", | ||
844 | &loprefix)) | ||
802 | loprefix = GNUNET_strdup (""); | 845 | loprefix = GNUNET_strdup (""); |
803 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string ( | 846 | if (GNUNET_OK != |
804 | cm->h->cfg, "arm", "OPTIONS", &lopostfix)) | 847 | GNUNET_CONFIGURATION_get_value_string (cm->h->cfg, |
848 | "arm", | ||
849 | "OPTIONS", | ||
850 | &lopostfix)) | ||
805 | lopostfix = GNUNET_strdup (""); | 851 | lopostfix = GNUNET_strdup (""); |
806 | if (GNUNET_OK != | 852 | if (GNUNET_OK != |
807 | GNUNET_CONFIGURATION_get_value_string (cm->h->cfg, | 853 | GNUNET_CONFIGURATION_get_value_string (cm->h->cfg, |
@@ -847,27 +893,41 @@ arm_service_report (void *cls, | |||
847 | /* Means we are ONLY running locally */ | 893 | /* Means we are ONLY running locally */ |
848 | /* we're clearly running a test, don't daemonize */ | 894 | /* we're clearly running a test, don't daemonize */ |
849 | if (NULL == config) | 895 | if (NULL == config) |
850 | proc = GNUNET_OS_start_process_s (GNUNET_NO, cm->std_inheritance, | 896 | proc = GNUNET_OS_start_process_s (GNUNET_NO, |
851 | NULL, loprefix, quotedbinary, | 897 | cm->std_inheritance, |
898 | NULL, | ||
899 | loprefix, | ||
900 | quotedbinary, | ||
852 | /* no daemonization! */ | 901 | /* no daemonization! */ |
853 | lopostfix, NULL); | 902 | lopostfix, NULL); |
854 | else | 903 | else |
855 | proc = GNUNET_OS_start_process_s (GNUNET_NO, cm->std_inheritance, | 904 | proc = GNUNET_OS_start_process_s (GNUNET_NO, |
856 | NULL, loprefix, quotedbinary, "-c", config, | 905 | cm->std_inheritance, |
906 | NULL, | ||
907 | loprefix, | ||
908 | quotedbinary, | ||
909 | "-c", config, | ||
857 | /* no daemonization! */ | 910 | /* no daemonization! */ |
858 | lopostfix, NULL); | 911 | lopostfix, NULL); |
859 | } | 912 | } |
860 | else | 913 | else |
861 | { | 914 | { |
862 | if (NULL == config) | 915 | if (NULL == config) |
863 | proc = GNUNET_OS_start_process_s (GNUNET_NO, cm->std_inheritance, | 916 | proc = GNUNET_OS_start_process_s (GNUNET_NO, |
864 | NULL, loprefix, quotedbinary, | 917 | cm->std_inheritance, |
918 | NULL, | ||
919 | loprefix, | ||
920 | quotedbinary, | ||
865 | "-d", lopostfix, NULL); | 921 | "-d", lopostfix, NULL); |
866 | else | 922 | else |
867 | proc = GNUNET_OS_start_process_s (GNUNET_NO, cm->std_inheritance, | 923 | proc = GNUNET_OS_start_process_s (GNUNET_NO, |
868 | NULL, loprefix, quotedbinary, "-c", | 924 | cm->std_inheritance, |
869 | config, | 925 | NULL, |
870 | "-d", lopostfix, NULL); | 926 | loprefix, |
927 | quotedbinary, | ||
928 | "-c", config, | ||
929 | "-d", lopostfix, | ||
930 | NULL); | ||
871 | } | 931 | } |
872 | GNUNET_free (binary); | 932 | GNUNET_free (binary); |
873 | GNUNET_free (quotedbinary); | 933 | GNUNET_free (quotedbinary); |
@@ -901,13 +961,16 @@ arm_service_report (void *cls, | |||
901 | * @param service_name name of the service | 961 | * @param service_name name of the service |
902 | * @param timeout how long to wait before failing for good | 962 | * @param timeout how long to wait before failing for good |
903 | * @param cb callback to invoke when service is ready | 963 | * @param cb callback to invoke when service is ready |
904 | * @param cb_cls closure for callback | 964 | * @param cb_cls closure for @a cb |
905 | * @param type type of the request | 965 | * @param type type of the request |
906 | */ | 966 | */ |
907 | static void | 967 | static void |
908 | change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | 968 | change_service (struct GNUNET_ARM_Handle *h, |
909 | struct GNUNET_TIME_Relative timeout, GNUNET_ARM_ResultCallback cb, | 969 | const char *service_name, |
910 | void *cb_cls, uint16_t type) | 970 | struct GNUNET_TIME_Relative timeout, |
971 | GNUNET_ARM_ResultCallback cb, | ||
972 | void *cb_cls, | ||
973 | uint16_t type) | ||
911 | { | 974 | { |
912 | struct ARMControlMessage *cm; | 975 | struct ARMControlMessage *cm; |
913 | size_t slen; | 976 | size_t slen; |
@@ -942,11 +1005,13 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
942 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (cm->timeout), | 1005 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (cm->timeout), |
943 | GNUNET_NO)); | 1006 | GNUNET_NO)); |
944 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, | 1007 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, |
945 | h->control_pending_tail, cm); | 1008 | h->control_pending_tail, |
1009 | cm); | ||
946 | cm->timeout_task_id = | 1010 | cm->timeout_task_id = |
947 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1011 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
948 | (cm->timeout), | 1012 | (cm->timeout), |
949 | &control_message_timeout, cm); | 1013 | &control_message_timeout, |
1014 | cm); | ||
950 | trigger_next_request (h, GNUNET_NO); | 1015 | trigger_next_request (h, GNUNET_NO); |
951 | } | 1016 | } |
952 | 1017 | ||
@@ -959,7 +1024,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
959 | * @param std_inheritance inheritance of std streams | 1024 | * @param std_inheritance inheritance of std streams |
960 | * @param timeout how long to wait before failing for good | 1025 | * @param timeout how long to wait before failing for good |
961 | * @param cont callback to invoke after request is sent or not sent | 1026 | * @param cont callback to invoke after request is sent or not sent |
962 | * @param cont_cls closure for callback | 1027 | * @param cont_cls closure for @a cont |
963 | */ | 1028 | */ |
964 | void | 1029 | void |
965 | GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, | 1030 | GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, |
@@ -1037,11 +1102,16 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, | |||
1037 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1102 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1038 | "Service test is already in progress, we're busy\n"); | 1103 | "Service test is already in progress, we're busy\n"); |
1039 | if (NULL != cont) | 1104 | if (NULL != cont) |
1040 | cont (cont_cls, GNUNET_ARM_REQUEST_BUSY, NULL, 0); | 1105 | cont (cont_cls, |
1106 | GNUNET_ARM_REQUEST_BUSY, | ||
1107 | NULL, 0); | ||
1041 | } | 1108 | } |
1042 | return; | 1109 | return; |
1043 | } | 1110 | } |
1044 | change_service (h, service_name, timeout, cont, cont_cls, | 1111 | change_service (h, |
1112 | service_name, | ||
1113 | timeout, | ||
1114 | cont, cont_cls, | ||
1045 | GNUNET_MESSAGE_TYPE_ARM_START); | 1115 | GNUNET_MESSAGE_TYPE_ARM_START); |
1046 | } | 1116 | } |
1047 | 1117 | ||
@@ -1058,7 +1128,7 @@ GNUNET_ARM_request_service_start (struct GNUNET_ARM_Handle *h, | |||
1058 | * @param service_name name of the service | 1128 | * @param service_name name of the service |
1059 | * @param timeout how long to wait before failing for good | 1129 | * @param timeout how long to wait before failing for good |
1060 | * @param cont callback to invoke after request is sent or is not sent | 1130 | * @param cont callback to invoke after request is sent or is not sent |
1061 | * @param cont_cls closure for callback | 1131 | * @param cont_cls closure for @a cont |
1062 | */ | 1132 | */ |
1063 | void | 1133 | void |
1064 | GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, | 1134 | GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, |
@@ -1070,8 +1140,13 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, | |||
1070 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1140 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1071 | "Stopping service `%s' within %s\n", | 1141 | "Stopping service `%s' within %s\n", |
1072 | service_name, | 1142 | service_name, |
1073 | GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_NO)); | 1143 | GNUNET_STRINGS_relative_time_to_string (timeout, |
1074 | change_service (h, service_name, timeout, cont, cont_cls, | 1144 | GNUNET_NO)); |
1145 | change_service (h, | ||
1146 | service_name, | ||
1147 | timeout, | ||
1148 | cont, | ||
1149 | cont_cls, | ||
1075 | GNUNET_MESSAGE_TYPE_ARM_STOP); | 1150 | GNUNET_MESSAGE_TYPE_ARM_STOP); |
1076 | } | 1151 | } |
1077 | 1152 | ||
@@ -1082,7 +1157,7 @@ GNUNET_ARM_request_service_stop (struct GNUNET_ARM_Handle *h, | |||
1082 | * @param h handle to ARM | 1157 | * @param h handle to ARM |
1083 | * @param timeout how long to wait before failing for good | 1158 | * @param timeout how long to wait before failing for good |
1084 | * @param cont callback to invoke after request is sent or is not sent | 1159 | * @param cont callback to invoke after request is sent or is not sent |
1085 | * @param cont_cls closure for callback | 1160 | * @param cont_cls closure for @a cont |
1086 | */ | 1161 | */ |
1087 | void | 1162 | void |
1088 | GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | 1163 | GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, |
@@ -1095,7 +1170,8 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | |||
1095 | 1170 | ||
1096 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1171 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1097 | "Requesting LIST from ARM service with timeout: %s\n", | 1172 | "Requesting LIST from ARM service with timeout: %s\n", |
1098 | GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); | 1173 | GNUNET_STRINGS_relative_time_to_string (timeout, |
1174 | GNUNET_YES)); | ||
1099 | cm = GNUNET_new (struct ARMControlMessage); | 1175 | cm = GNUNET_new (struct ARMControlMessage); |
1100 | cm->h = h; | 1176 | cm->h = h; |
1101 | cm->list_cont = cont; | 1177 | cm->list_cont = cont; |
@@ -1107,12 +1183,15 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | |||
1107 | msg->reserved = htonl (0); | 1183 | msg->reserved = htonl (0); |
1108 | cm->msg = msg; | 1184 | cm->msg = msg; |
1109 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, | 1185 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, |
1110 | h->control_pending_tail, cm); | 1186 | h->control_pending_tail, |
1187 | cm); | ||
1111 | cm->timeout_task_id = | 1188 | cm->timeout_task_id = |
1112 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 1189 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
1113 | (cm->timeout), | 1190 | (cm->timeout), |
1114 | &control_message_timeout, cm); | 1191 | &control_message_timeout, |
1115 | trigger_next_request (h, GNUNET_NO); | 1192 | cm); |
1193 | trigger_next_request (h, | ||
1194 | GNUNET_NO); | ||
1116 | } | 1195 | } |
1117 | 1196 | ||
1118 | 1197 | ||