apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 55928] New: fix POSIX shared memory (shm_open) use for named shared memory
Date Mon, 23 Dec 2013 18:24:02 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=55928

            Bug ID: 55928
           Summary: fix POSIX shared memory (shm_open) use for named
                    shared memory
           Product: APR
           Version: HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: jh-asf@skrt.org

Created attachment 31150
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31150&action=edit
fix POSIX shared memory support, conditioned by --enable-posix-shm

When APR's configure script tries to decide which mechanism to use for named
shared memory, it probes for POSIX.1 shm_open support first, but then it checks
for SysV shared memory support and overrides the earlier decision.  Systems
that support POSIX shared memory also support the older SysV shared memory API,
so in practice POSIX shared memory is never selected.  If it were selected, it
would not work because the apr_shm_attach function lacks the implementation for
that case.

The advantage to the user that the POSIX shared memory API offers over the SysV
shared memory API on systems that support both, such as Linux, is that the
former refers to shared memory objects by name, whereas the latter refers to
them by a 32-bit key_id.  The ID is prone to collisions.  The fix in [bug
53996] presumably reduces the probability of colliding on this ID, but the
shm_open API does not have an ID collision problem in the first place.

The attached patch moves the probe for shm_open (POSIX shm) after the probe for
shmget (SysV shm), but also makes the shm_open probe conditioned by a new
configure option: --enable-posix-shm, so that this does not change the decision
in practice for people who do not opt into the change.

The patch also corrects a few problems that were preventing the existing
implementation from working correctly when the named shared memory decision was
to use the POSIX shared memory API.  In particular, the names of shared memory
objects should not contain slashes after the leading slash, and therefore this
patch encodes the passed-in shm name to comply with the API requirement.


Description header for the patch:

fix POSIX shared memory support, conditioned by --enable-posix-shm

* Probe for POSIX shared memory after probing for SysV IPC because
  otherwise SysV IPC always takes over.
* Only do this if --enable-posix-shm was passed to configure.
  This is to maintain backwards compatibility with before this change
  when the probe was never effective.
* Fix apr_shm_attach for when POSIX shared memory is used.
* Encode the shm name passed to shm_open and shm_unlink to comply
  with the functions' requirement on the format.  Without this,
  apache httpd fails trying to create shm with slashes in the name.
* create the POSIX shared memory with mode 0600, instead of 0644
* destroying an unlinked POSIX shm is ok, just like for a SysV shim

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message