diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-13 22:07:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-13 22:07:29 +0000 |
commit | b9e05ddfffa6e716b1e725d367d6dc3e2a1cde02 (patch) | |
tree | 34b775b9f7aee30925ec7ff7901ffeb0e5cd3690 /src/arm | |
parent | a256932620856c72b3dd3bd53d8aef86c4688abc (diff) | |
download | gnunet-b9e05ddfffa6e716b1e725d367d6dc3e2a1cde02.tar.gz gnunet-b9e05ddfffa6e716b1e725d367d6dc3e2a1cde02.zip |
-fix message alignment to avoid bus error, indentation, style fixes
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/arm.h | 11 | ||||
-rw-r--r-- | src/arm/arm_api.c | 5 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm.c | 84 |
3 files changed, 58 insertions, 42 deletions
diff --git a/src/arm/arm.h b/src/arm/arm.h index 7010a0842..bf2f7e797 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h | |||
@@ -57,13 +57,18 @@ struct GNUNET_ARM_StatusMessage | |||
57 | struct GNUNET_ARM_Message | 57 | struct GNUNET_ARM_Message |
58 | { | 58 | { |
59 | /** | 59 | /** |
60 | * Reply to client, type is GNUNET_MESSAGE_TYPE_ARM_RESULT or | 60 | * Reply to client, type is #GNUNET_MESSAGE_TYPE_ARM_RESULT or |
61 | * GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT. | 61 | * #GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT. |
62 | * OR | 62 | * OR |
63 | * Request from client, type is GNUNET_MESSAGE_TYPE_ARM_REQUEST | 63 | * Request from client, type is #GNUNET_MESSAGE_TYPE_ARM_REQUEST |
64 | */ | 64 | */ |
65 | struct GNUNET_MessageHeader header; | 65 | struct GNUNET_MessageHeader header; |
66 | 66 | ||
67 | /** | ||
68 | * For alignment. | ||
69 | */ | ||
70 | uint32_t reserved; | ||
71 | |||
67 | /** | 72 | /** |
68 | * ID of a request that is being replied to. | 73 | * ID of a request that is being replied to. |
69 | * OR | 74 | * OR |
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 6dfe65702..9644026d6 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -348,6 +348,7 @@ client_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | arm_msg = (const struct GNUNET_ARM_Message *) msg; | 350 | arm_msg = (const struct GNUNET_ARM_Message *) msg; |
351 | GNUNET_break (0 == ntohl (arm_msg->reserved)); | ||
351 | id = GNUNET_ntohll (arm_msg->request_id); | 352 | id = GNUNET_ntohll (arm_msg->request_id); |
352 | cm = find_cm_by_id (h, id); | 353 | cm = find_cm_by_id (h, id); |
353 | if (NULL == cm) | 354 | if (NULL == cm) |
@@ -529,6 +530,7 @@ transmit_arm_message (void *cls, size_t size, void *buf) | |||
529 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 530 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
530 | "Transmitting control message with %u bytes of type %u to arm with id %llu\n", | 531 | "Transmitting control message with %u bytes of type %u to arm with id %llu\n", |
531 | (unsigned int) msize, (unsigned int) ntohs (cm->msg->header.type), request_id); | 532 | (unsigned int) msize, (unsigned int) ntohs (cm->msg->header.type), request_id); |
533 | arm_msg->reserved = htonl (0); | ||
532 | arm_msg->request_id = GNUNET_htonll (request_id); | 534 | arm_msg->request_id = GNUNET_htonll (request_id); |
533 | memcpy (buf, cm->msg, msize); | 535 | memcpy (buf, cm->msg, msize); |
534 | /* Otherwise we won't be able to find it later! */ | 536 | /* Otherwise we won't be able to find it later! */ |
@@ -712,6 +714,7 @@ control_message_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t | |||
712 | { | 714 | { |
713 | struct ARMControlMessage *cm = cls; | 715 | struct ARMControlMessage *cm = cls; |
714 | struct GNUNET_ARM_Message *arm_msg; | 716 | struct GNUNET_ARM_Message *arm_msg; |
717 | |||
715 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 718 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
716 | "Control message timed out\n"); | 719 | "Control message timed out\n"); |
717 | arm_msg = cm->msg; | 720 | arm_msg = cm->msg; |
@@ -908,6 +911,7 @@ change_service (struct GNUNET_ARM_Handle *h, const char *service_name, | |||
908 | msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message) + slen); | 911 | msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message) + slen); |
909 | msg->header.size = htons (sizeof (struct GNUNET_ARM_Message) + slen); | 912 | msg->header.size = htons (sizeof (struct GNUNET_ARM_Message) + slen); |
910 | msg->header.type = htons (type); | 913 | msg->header.type = htons (type); |
914 | msg->reserved = htonl (0); | ||
911 | memcpy (&msg[1], service_name, slen); | 915 | memcpy (&msg[1], service_name, slen); |
912 | cm->msg = msg; | 916 | cm->msg = msg; |
913 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 917 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1068,6 +1072,7 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, | |||
1068 | msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message)); | 1072 | msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message)); |
1069 | msg->header.size = htons (sizeof (struct GNUNET_ARM_Message)); | 1073 | msg->header.size = htons (sizeof (struct GNUNET_ARM_Message)); |
1070 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ARM_LIST); | 1074 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ARM_LIST); |
1075 | msg->reserved = htonl (0); | ||
1071 | cm->msg = msg; | 1076 | cm->msg = msg; |
1072 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, | 1077 | GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head, |
1073 | h->control_pending_tail, cm); | 1078 | h->control_pending_tail, cm); |
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index eccd8d566..44decaa7f 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -731,31 +731,34 @@ handle_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
731 | size -= sizeof (struct GNUNET_ARM_Message); | 731 | size -= sizeof (struct GNUNET_ARM_Message); |
732 | servicename = (const char *) &amsg[1]; | 732 | servicename = (const char *) &amsg[1]; |
733 | if ((size == 0) || (servicename[size - 1] != '\0')) | 733 | if ((size == 0) || (servicename[size - 1] != '\0')) |
734 | { | 734 | { |
735 | GNUNET_break (0); | 735 | GNUNET_break (0); |
736 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 736 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
737 | return; | 737 | return; |
738 | } | 738 | } |
739 | if (GNUNET_YES == in_shutdown) | 739 | if (GNUNET_YES == in_shutdown) |
740 | { | 740 | { |
741 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_IN_SHUTDOWN); | 741 | signal_result (client, servicename, request_id, |
742 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 742 | GNUNET_ARM_RESULT_IN_SHUTDOWN); |
743 | return; | 743 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
744 | } | 744 | return; |
745 | } | ||
745 | sl = find_service (servicename); | 746 | sl = find_service (servicename); |
746 | if (NULL == sl) | 747 | if (NULL == sl) |
747 | { | 748 | { |
748 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_IS_NOT_KNOWN); | 749 | signal_result (client, servicename, request_id, |
749 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 750 | GNUNET_ARM_RESULT_IS_NOT_KNOWN); |
750 | return; | 751 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
751 | } | 752 | return; |
753 | } | ||
752 | sl->is_default = GNUNET_YES; | 754 | sl->is_default = GNUNET_YES; |
753 | if (sl->proc != NULL) | 755 | if (NULL != sl->proc) |
754 | { | 756 | { |
755 | signal_result (client, servicename, request_id, GNUNET_ARM_RESULT_IS_STARTED_ALREADY); | 757 | signal_result (client, servicename, request_id, |
756 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 758 | GNUNET_ARM_RESULT_IS_STARTED_ALREADY); |
757 | return; | 759 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
758 | } | 760 | return; |
761 | } | ||
759 | start_process (sl, client, request_id); | 762 | start_process (sl, client, request_id); |
760 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 763 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
761 | } | 764 | } |
@@ -806,7 +809,8 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client, | |||
806 | return; | 809 | return; |
807 | } | 810 | } |
808 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 811 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
809 | _("Preparing to stop `%s'\n"), servicename); | 812 | _("Preparing to stop `%s'\n"), |
813 | servicename); | ||
810 | if (0 == strcasecmp (servicename, "arm")) | 814 | if (0 == strcasecmp (servicename, "arm")) |
811 | { | 815 | { |
812 | broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL); | 816 | broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL); |
@@ -831,22 +835,22 @@ handle_stop (void *cls, struct GNUNET_SERVER_Client *client, | |||
831 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 835 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
832 | return; | 836 | return; |
833 | } | 837 | } |
834 | if (sl->killing_client != NULL) | 838 | if (NULL != sl->killing_client) |
835 | { | 839 | { |
836 | /* killing already in progress */ | 840 | /* killing already in progress */ |
837 | signal_result (client, servicename, request_id, | 841 | signal_result (client, servicename, request_id, |
838 | GNUNET_ARM_RESULT_IS_STOPPING_ALREADY); | 842 | GNUNET_ARM_RESULT_IS_STOPPING_ALREADY); |
839 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 843 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
840 | return; | 844 | return; |
841 | } | 845 | } |
842 | if (sl->proc == NULL) | 846 | if (NULL == sl->proc) |
843 | { | 847 | { |
844 | /* process is down */ | 848 | /* process is down */ |
845 | signal_result (client, servicename, request_id, | 849 | signal_result (client, servicename, request_id, |
846 | GNUNET_ARM_RESULT_IS_STOPPED_ALREADY); | 850 | GNUNET_ARM_RESULT_IS_STOPPED_ALREADY); |
847 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 851 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
848 | return; | 852 | return; |
849 | } | 853 | } |
850 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 854 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
851 | "Sending kill signal to service `%s', waiting for process to die.\n", | 855 | "Sending kill signal to service `%s', waiting for process to die.\n", |
852 | servicename); | 856 | servicename); |
@@ -884,10 +888,11 @@ handle_list (void *cls, struct GNUNET_SERVER_Client *client, | |||
884 | return; | 888 | return; |
885 | 889 | ||
886 | request = (struct GNUNET_ARM_Message *) message; | 890 | request = (struct GNUNET_ARM_Message *) message; |
891 | GNUNET_break (0 == ntohl (request->reserved)); | ||
887 | count = 0; | 892 | count = 0; |
888 | string_list_size = 0; | 893 | string_list_size = 0; |
889 | /* first count the running processes get their name's size */ | 894 | /* first count the running processes get their name's size */ |
890 | for (sl = running_head; sl != NULL; sl = sl->next) | 895 | for (sl = running_head; NULL != sl; sl = sl->next) |
891 | { | 896 | { |
892 | if (sl->proc != NULL) | 897 | if (sl->proc != NULL) |
893 | { | 898 | { |
@@ -903,6 +908,7 @@ handle_list (void *cls, struct GNUNET_SERVER_Client *client, | |||
903 | msg = GNUNET_malloc (total_size); | 908 | msg = GNUNET_malloc (total_size); |
904 | msg->arm_msg.header.size = total_size; | 909 | msg->arm_msg.header.size = total_size; |
905 | msg->arm_msg.header.type = GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT; | 910 | msg->arm_msg.header.type = GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT; |
911 | msg->arm_msg.reserved = htonl (0); | ||
906 | msg->arm_msg.request_id = GNUNET_ntohll (request->request_id); | 912 | msg->arm_msg.request_id = GNUNET_ntohll (request->request_id); |
907 | msg->count = count; | 913 | msg->count = count; |
908 | 914 | ||