On Wed, May 26, 2004 at 08:17:46AM -0400, [EMAIL PROTECTED] wrote: > Linux supports both anonymous and named shared memory. By default though, > Linux is using SHMGET in APR, which is named, but not backed by a file. > You will get APR_EEXIST if the semaphore already exists, this can be > checked by running ipcs.
This stuff is a complete mess in APR. The name-based shmget method *does* use and create a real file, but it's redundant AFAICT; all it does is store the size of the segment, which shmctl will tell you anyway on. An uncleanly shutdown httpd (kill -9 or pull the plug) will leave around both the shm segment *and* the file, and APR will give EEXIST when trying to create either, so you have this fun routine: 0. server reboots after power loss 1. start httpd: open(O_CREAT) => EEXIST 2. admin scratches head, removes file 3. start httpd: open(O_CREAT) => ok! shmget(IPC_CREAT) => EEXIST 4. admin scratches head, searches bugzilla, learns how to use ipcs/ipcrm 5. start httpd: open(O_CREAT) => EXIST 6. admin goes crazy in the end using anonyous shm everywhere was easier than fixing all the FIXMEs in the shm code where it should have had real error handling, so I gave up with this stuff. joe
