System V Semaphores
| From: | Philip Murray | Date: | Tue, 10 Apr 2001 22:07:54 +0000 |
| Subject: | System V Semaphores | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-48091@lists.php.net to get a copy of this message | ||
Hi,
I've been trying to use SystemV Semaphores as a kind of locking system in a
webpage, but after a few hours I get this message:
Warning: semget() failed for key 0x0: No space left on device in
/1/home/xxxx/admin/htdocs/prop/lock.php on line 8
Warning: 0 is not a SysV semaphore index in
/1/home/xxxx/admin/htdocs/prop/lock.php on line 19
Couldn't grab lock!
It isn't disk space, and there's plenty of free memory. So how do I fix it
and stop it doing it in the future?
Apart from this it seems to work fine. I've attached some sample code which
is pretty much exactly what I'm doing.
Cheers
<? class Lock { var $lock = 1; var $id; function Lock() { $this->id = sem_get($lock); } function unLock() { sem_release($this->id); return 0; } function checkLock() { if(!sem_acquire($this->id)) { echo "Couldn't grab lock!"; return -1; } return 0; } } ?>
<? class Lock { var $lock = 1; var $id; function Lock() { $this->id = sem_get($lock); } function unLock() { sem_release($this->id); return 0; } function checkLock() { if(!sem_acquire($this->id)) { echo "Couldn't grab lock!"; return -1; } return 0; } } ?>