apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tyler MacDonald <ty...@yi.org>
Subject Re: RFC: graceful handling of abandoned shared memory
Date Wed, 26 Apr 2006 22:23:54 GMT

... after unplugging the computer and plugging it back in, I realised I
messed up on apr0_shm_remove. Here's the corrected version:

static int apr0_shm_remove (const char *shfile, apr_pool_t *p) {
 int ret;
 apr_shm_t* shmem = NULL;

 if((ret = apr_shm_attach(&shmem, shfile, p)) != APR_SUCCESS) {
  if(APR_STATUS_IS_EINVAL(ret) || APR_STATUS_IS_ENOENT(ret)) {
   ret = apr_file_remove(shfile, p);
   if(APR_STATUS_IS_ENOENT(ret)) {
    return APR_SUCCESS;
   } else {
    return ret;
   }
  }
  return ret;
 } else {
   return apr_shm_destroy(shmem);
 }     
}

	Cheers,
		Tyler



Tyler MacDonald <tyler@yi.org> wrote:
> > > apr_shm_remove()! :)
> 
> 	... not under apr-0 unfortunately, but I've worked around it. :-)
> 
> > I'm guessing other processes could still write to the shared memory under
> > the SysV model (since the file is just a pointer to a memory address), what
> > about under mmap?
> 
> 	Here's what I've come up with. Check out new_shmem_segment() and
> apr0_shm_remove() and let me know what you think.
> 
> 	Thanks,
> 		Tyler

Mime
View raw message