using semaphores problem
| From: | Thomas | Date: | Tue, 04 Dec 2001 10:59:03 +0000 |
| Subject: | using semaphores problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-76495@lists.php.net to get a copy of this message | ||
Hello there,
I am using semaphores to synchronize access to specific database
records. Problem is, it does not seem that the semaphores are being
released. Not only am I using sem_release() but the PHP manual says it
will release all semaphores that are still acquired at the end of the
PHP page loading.
Here is my simple code:
function writeLock($mid) {
if(!$mid) mydi('attempt to lock data 0');
if(!($lock_id = sem_get(2500+200+$mid%100)) || !sem_acquire($lock_id))
mydi('locking match.');
return $lock_id;
}
=AND=
function unwriteLock($lock_id) {
if(!$lock_id) mydi('attempt to unlock 0');
if(!sem_release($lock_id))
mydi('unlocking information.');
}
Suggestions?