I had the same issue. It appears to be bug in apr_shm_create in 
Apache 2.0. The bug is hard to characterize. The first time i start 
it would fail. (My filename was based on pid of the httpd process. 
Then i would stop apache & restart retaining the old shmem file, it 
would work. If i cleanup the old shmem file it would not.

I have finally managed to workaround it.
Instead of passing a filename to apr_shm_create i pass a NULL.
Now im able to predictably create/allocate shared memory

--- In [EMAIL PROTECTED], "Nedelcho Stanev" <[EMAIL PROTECTED]> 
wrote:
> sending this twice, since i did'n get this in mail list.
> may be there are some problem ?
> 
> ----- Original Message ----- 
> From: Nedelcho Stanev 
> To: [EMAIL PROTECTED] 
> Sent: Friday, August 15, 2003 2:43 PM
> Subject: apr_shm_create
> 
> 
> Hello All,
> 
> i have this problem when i use shared memory with Apache.
> Apache is 2.0.47, compiled on Red Hat linux 8 with kernel 2.4.18-14.
> Same module and same Apache on Windows work perfect, but on linux
> i have some problems.
> so ...
> i create shared memory block with 
> sts = apr_shm_create(&client_shm, shmem_size, MOD_MQUBE_SHMEMFILE, 
ctx);
> in initialize_module of my module.
> in same function i add cleanup callback with  
apr_pool_cleanup_register
> in this callbeck i do cleaning with
> apr_shm_destroy(client_shm);
> client_shm = NULL;
> 
> when i stop and start apache properly all works perfect :) but
> if server crash, or i kill it with -9 , then in /tmp directory i 
still have MOD_MQUBE_SHMEMFILE 
> file still. and this is ok, because cleanup callback is not called
> but when i start again apache apr_shm_create doesent work.
> goin in a deep, i see that in sorce of this function ( unix/shm.c)
> problem come from here :
> if ((new_m->shmid = shmget(shmkey, new_m->realsize,
> befor this line we have
> status = apr_file_open(&file, filename, 
> and this create file correctly
> but shmget return error - File exists
> 
> so, does anyone know why this happens? :)
> btw , same effect is if i don't delete this file from tmp directory
> but, even if i delete it apache cannot allocate shared memory.
> 
> 
> decho



Reply via email to