PHP no wait sem_acquire?
- by SerEnder
Not a specific code question, but more of a general coding question. I'm trying to use a semaphore in a work project to limit the number of users that can access certain processes at a concurrent time.
From my understanding the following:
$iKey = ftock($sSomeFileLocation,'sOneCharacterString'); //Generate the key
if($sem_id = sem_get($iKey){ //1 user allowed
if(sem_acquire($sem_id)){
//Do the limited process here
sem_release($sem_id);
}
}
The problem that I see here is that if there is already one user who has the semaphore key, then the next user just waits until the first user is done rather than just faulting out. Anyone know of a way that if the max_acquire number has been reached, sem_acquire (or similar) will just return false?
Thanks