gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30677 - gnunet/src/arm


From: gnunet
Subject: [GNUnet-SVN] r30677 - gnunet/src/arm
Date: Wed, 13 Nov 2013 23:07:29 +0100

Author: grothoff
Date: 2013-11-13 23:07:29 +0100 (Wed, 13 Nov 2013)
New Revision: 30677

Modified:
   gnunet/src/arm/arm.h
   gnunet/src/arm/arm_api.c
   gnunet/src/arm/gnunet-service-arm.c
Log:
-fix message alignment to avoid bus error, indentation, style fixes

Modified: gnunet/src/arm/arm.h
===================================================================
--- gnunet/src/arm/arm.h        2013-11-13 21:51:21 UTC (rev 30676)
+++ gnunet/src/arm/arm.h        2013-11-13 22:07:29 UTC (rev 30677)
@@ -57,13 +57,18 @@
 struct GNUNET_ARM_Message
 {
   /**
-   * Reply to client, type is GNUNET_MESSAGE_TYPE_ARM_RESULT or
-   * GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT.
+   * Reply to client, type is #GNUNET_MESSAGE_TYPE_ARM_RESULT or
+   * #GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT.
    * OR
-   * Request from client, type is GNUNET_MESSAGE_TYPE_ARM_REQUEST
+   * Request from client, type is #GNUNET_MESSAGE_TYPE_ARM_REQUEST
    */
   struct GNUNET_MessageHeader header;
 
+  /** 
+   * For alignment.
+   */
+  uint32_t reserved;
+
   /**
    * ID of a request that is being replied to.
    * OR

Modified: gnunet/src/arm/arm_api.c
===================================================================
--- gnunet/src/arm/arm_api.c    2013-11-13 21:51:21 UTC (rev 30676)
+++ gnunet/src/arm/arm_api.c    2013-11-13 22:07:29 UTC (rev 30677)
@@ -348,6 +348,7 @@
     return;
   }
   arm_msg = (const struct GNUNET_ARM_Message *) msg;
+  GNUNET_break (0 == ntohl (arm_msg->reserved));
   id = GNUNET_ntohll (arm_msg->request_id);
   cm = find_cm_by_id (h, id);
   if (NULL == cm)
@@ -529,6 +530,7 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Transmitting control message with %u bytes of type %u to arm with id 
%llu\n",
        (unsigned int) msize, (unsigned int) ntohs (cm->msg->header.type), 
request_id);
+  arm_msg->reserved = htonl (0);
   arm_msg->request_id = GNUNET_htonll (request_id);
   memcpy (buf, cm->msg, msize);
   /* Otherwise we won't be able to find it later! */
@@ -712,6 +714,7 @@
 {
   struct ARMControlMessage *cm = cls;
   struct GNUNET_ARM_Message *arm_msg;
+
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Control message timed out\n");
   arm_msg = cm->msg;
@@ -908,6 +911,7 @@
   msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message) + slen);
   msg->header.size = htons (sizeof (struct GNUNET_ARM_Message) + slen);
   msg->header.type = htons (type);
+  msg->reserved = htonl (0);
   memcpy (&msg[1], service_name, slen);
   cm->msg = msg;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1068,6 +1072,7 @@
   msg = GNUNET_malloc (sizeof (struct GNUNET_ARM_Message));
   msg->header.size = htons (sizeof (struct GNUNET_ARM_Message));
   msg->header.type = htons (GNUNET_MESSAGE_TYPE_ARM_LIST);
+  msg->reserved = htonl (0);
   cm->msg = msg;
   GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head,
                                     h->control_pending_tail, cm);

Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2013-11-13 21:51:21 UTC (rev 30676)
+++ gnunet/src/arm/gnunet-service-arm.c 2013-11-13 22:07:29 UTC (rev 30677)
@@ -731,31 +731,34 @@
   size -= sizeof (struct GNUNET_ARM_Message);
   servicename = (const char *) &amsg[1];
   if ((size == 0) || (servicename[size - 1] != '\0'))
-    {
-      GNUNET_break (0);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-      return;
-    }
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
   if (GNUNET_YES == in_shutdown)
-    {
-      signal_result (client, servicename, request_id, 
GNUNET_ARM_RESULT_IN_SHUTDOWN);
-      GNUNET_SERVER_receive_done (client, GNUNET_OK);
-      return;
-    }
+  {
+    signal_result (client, servicename, request_id, 
+                  GNUNET_ARM_RESULT_IN_SHUTDOWN);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
   sl = find_service (servicename);
   if (NULL == sl)
-    {
-      signal_result (client, servicename, request_id, 
GNUNET_ARM_RESULT_IS_NOT_KNOWN);
-      GNUNET_SERVER_receive_done (client, GNUNET_OK);
-      return;
-    }
+  {
+    signal_result (client, servicename, request_id, 
+                  GNUNET_ARM_RESULT_IS_NOT_KNOWN);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
   sl->is_default = GNUNET_YES;
-  if (sl->proc != NULL)
-    {
-      signal_result (client, servicename, request_id, 
GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
-      GNUNET_SERVER_receive_done (client, GNUNET_OK);
-      return;
-    }
+  if (NULL != sl->proc)
+  {
+    signal_result (client, servicename, request_id,
+                  GNUNET_ARM_RESULT_IS_STARTED_ALREADY);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
   start_process (sl, client, request_id);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
@@ -806,7 +809,8 @@
       return;
     }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("Preparing to stop `%s'\n"), servicename);
+             _("Preparing to stop `%s'\n"), 
+             servicename);
   if (0 == strcasecmp (servicename, "arm"))
   {
     broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
@@ -831,22 +835,22 @@
       GNUNET_SERVER_receive_done (client, GNUNET_OK);
       return;
     }
-  if (sl->killing_client != NULL)
-    {
-      /* killing already in progress */
-      signal_result (client, servicename, request_id,
-          GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
-      GNUNET_SERVER_receive_done (client, GNUNET_OK);
-      return;
-    }
-  if (sl->proc == NULL)
-    {
-      /* process is down */
-      signal_result (client, servicename, request_id,
-          GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
-      GNUNET_SERVER_receive_done (client, GNUNET_OK);
-      return;
-    }
+  if (NULL != sl->killing_client)
+  {
+    /* killing already in progress */
+    signal_result (client, servicename, request_id,
+                  GNUNET_ARM_RESULT_IS_STOPPING_ALREADY);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
+  if (NULL == sl->proc)
+  {
+    /* process is down */
+    signal_result (client, servicename, request_id,
+                  GNUNET_ARM_RESULT_IS_STOPPED_ALREADY);
+    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    return;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Sending kill signal to service `%s', waiting for process to 
die.\n",
              servicename);
@@ -884,10 +888,11 @@
     return;
 
   request = (struct GNUNET_ARM_Message *) message;
+  GNUNET_break (0 == ntohl (request->reserved));
   count = 0;
   string_list_size = 0;
   /* first count the running processes get their name's size */
-  for (sl = running_head; sl != NULL; sl = sl->next)
+  for (sl = running_head; NULL != sl; sl = sl->next)
   {
     if (sl->proc != NULL)
     {
@@ -903,6 +908,7 @@
   msg = GNUNET_malloc (total_size);
   msg->arm_msg.header.size = total_size;
   msg->arm_msg.header.type = GNUNET_MESSAGE_TYPE_ARM_LIST_RESULT;
+  msg->arm_msg.reserved = htonl (0);
   msg->arm_msg.request_id = GNUNET_ntohll (request->request_id);
   msg->count = count;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]