]> granicus.if.org Git - apache/commitdiff
Increase memory alignment for slotmem data in
authorRainer Jung <rjung@apache.org>
Mon, 17 Jan 2011 22:03:45 +0000 (22:03 +0000)
committerRainer Jung <rjung@apache.org>
Mon, 17 Jan 2011 22:03:45 +0000 (22:03 +0000)
mod_slotmem_shm.

Consumers still need to choose the slot sizes
appropriate for consistent alignment.
mod_slotmem_shm only cares about the alignment
for the first slot.

We use the APR default alignment.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1060108 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/slotmem/mod_slotmem_shm.c

diff --git a/CHANGES b/CHANGES
index 05563c8cca58f3a6d3a30db6c3b7954d2a0d763b..3d709e297839a618871a26bb0171ddc3abe74eaa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.11
 
+  *) mod_slotmem_shm: Increase memory alignment for slotmem data.
+     [Rainer Jung]
+
   *) mod_ssl: Add config options for OCSP: SSLOCSPResponderTimeout,
      SSLOCSPResponseMaxAge, SSLOCSPResponseTimeSkew.  
      [Kaspar Brand <httpd-dev.2011 velox.ch>]
index e3c688fc57af2ecb48af521aca1b3aa8840d8dc1..58e0420618f446ee8fdbe535e4722fc4b0879878 100644 (file)
@@ -51,6 +51,8 @@ typedef struct {
     ap_slotmem_type_t type;      /* type-specific flags */
 } sharedslotdesc_t;
 
+#define AP_SLOTMEM_OFFSET (APR_ALIGN_DEFAULT(sizeof(sharedslotdesc_t)))
+
 struct ap_slotmem_instance_t {
     char                 *name;       /* per segment name */
     void                 *shm;        /* ptr to memory segment (apr_shm_t *) */
@@ -253,7 +255,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
     const char *fname;
     apr_shm_t *shm;
     apr_size_t basesize = (item_size * item_num);
-    apr_size_t size = sizeof(sharedslotdesc_t) +
+    apr_size_t size = AP_SLOTMEM_OFFSET +
                       (item_num * sizeof(char)) + basesize;
     apr_status_t rv;
 
@@ -305,10 +307,10 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
             apr_shm_detach(shm);
             return APR_EINVAL;
         }
-        ptr = ptr + sizeof(desc);
+        ptr = ptr + AP_SLOTMEM_OFFSET;
     }
     else {
-        apr_size_t dsize = size - sizeof(sharedslotdesc_t);
+        apr_size_t dsize = size - AP_SLOTMEM_OFFSET;
         if (name && name[0] != ':') {
             apr_shm_remove(fname, gpool);
             rv = apr_shm_create(&shm, size, fname, gpool);
@@ -333,7 +335,7 @@ static apr_status_t slotmem_create(ap_slotmem_instance_t **new,
         desc.num = item_num;
         desc.type = type;
         memcpy(ptr, &desc, sizeof(desc));
-        ptr = ptr + sizeof(desc);
+        ptr = ptr + AP_SLOTMEM_OFFSET;
         memset(ptr, 0, dsize);
         /*
          * TODO: Error check the below... What error makes
@@ -418,7 +420,7 @@ static apr_status_t slotmem_attach(ap_slotmem_instance_t **new,
     /* Read the description of the slotmem */
     ptr = apr_shm_baseaddr_get(shm);
     memcpy(&desc, ptr, sizeof(desc));
-    ptr = ptr + sizeof(desc);
+    ptr = ptr + AP_SLOTMEM_OFFSET;
 
     /* For the chained slotmem stuff */
     res = (ap_slotmem_instance_t *) apr_pcalloc(gpool,