apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tyler MacDonald <ty...@yi.org>
Subject Re: Shared memory segment management
Date Thu, 20 Apr 2006 00:06:42 GMT
Michael Vergoz <mv@binarysec.com> wrote:
> I have made a small implementation of a new SHM design :
> http://www.badcode.be/~descript/.apache/
> 
> FEATURES:
> - "pager" allows you to specify a multiple of pages that may be used. It 
> reduces reallocation so it reduces kernel call.
> - Memory auto alignement
> - File map auto padding
> - Auto remove on bad header
> - Auto create if file doesn't exist
> - Remap/reallocation possibility.
> - Auto padding (mem/file) when reallocating.
> - Kernel lock/unlock.
> - Memory bridge capatibility.
> - 2 lock types.
> 
> This implementation was stoped because Apache folks have not been 
> interested by this code (this is probably because the code isn't "apr 
> ready")

Dirk Groeneveld also emailed me a patch he submitted awhile ago that didn't
get picked up, involving shared memory via the apr mutex routines. Both of
you have interesting approaches! Of course, I don't want my application to
only work with a custom-patched version of APR... I just want it to work,
and work properly, out-of-the-box.

Looking at shmctl's manpage, apparently there's an "shm_nattch" attribute
that tells me how many processes are currently attached to a shared memory
segment. What I'd *like* to do is this:

	1) Master tries to shm create first

	2) If that fails, master tries to shm attach

	3) If that succeeds, check shm_nattch

		- if we're the only one attached, wipe the segment clean for re-use

		- if others are attached, fatal error: we dont want two
		  masters using the same segment!

	4) If both attaching and creating are failing, there's nothing else
		we can do, so fatal error.

However, APR doesn't expose anything that would give us access to a
headcount for a shared memory space.... and perhaps rightly so, since this
data isn't available for all shared memory implementations (is it?)

Any thoughts on how to accomplish something like this without abandoning
APR? Or any way that such functionality could be worked into APR in the
future?

	Thanks,
		Tyler



Mime
View raw message