apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Rossi <...@brasko.net>
Subject global mutex
Date Thu, 14 Jan 2010 20:47:03 GMT
Hi,

I've noticed in the global mutex code, what I consider to be a problem.
I'm trying to get a global mutex, that multiple process's can use to
ensure 1 access at a time.

For APR_LOCK_SYSVSEM, in proc_mutex_sysv_create, semget is called with
IPC_PRIVATE, instead of using ftok to convert the filename passed in
to a key. Please correct me if I'm wrong, but this forces the lock to
only be useful in the same process, and with children of that process.
This isn't useful for me. Shouldn't ftok be called if the filename is
non NULL?

For APR_LOCK_FCNTL I notice a similar problem. In
proc_mutex_fcntl_create, after the file is created, it's unlinked. By
calling unlink, another process can't access it, to try to lock it. Was
does this function behave this way?
Also, for this case, if the file already exists on disk, you can't
open it, you get an error. Shouldn't it allow opening an already
existing file?

Now, on windows, using APR_LOCK_DEFAULT, it calls into
apr_proc_mutex_create. In this case, it uses CreateMutex but DOES
convert the filename into a key to pass into CreateMutex. This allows
multiple process's to lock on a key properly.

So, I've described a few cases. Windows works fine for me, UNIX does
not with both sysv and fcntl. Is this designed this way, or is it a
mistake? I would suggest mainly that the sysv semget function
use IPCPRIVATE when the fname is NULL and ftok when it's non NULL.
Thoughts?

Thanks,
Bob

Mime
View raw message