Not a specific code question, but a general coding question. I am trying to use a semaphore in a working project to limit the number of users who can access certain processes at the same time.
In my opinion, 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 a semaphore key, the next user just waits until the first user is made, and not just a crash. Does anyone know how, if the max_acquire number was reached, sem_acquire (or the like) would simply return false?
thanks
source share