EINTR error for semop call

I am using the following piece of code in a php script to update a share securely.

$lock_id = sem_get( ftok( 'tmp/this.lock', 'r'));
sem_acquire($lock_id)
//do something
sem_release($lock_id)

      

When I stress test this code with a lot of requests, I get the error:

Warning: semop() failed acquiring SYSVSEM_SETVAL for key 0x1e: No space left on device in blahblah.php on line 1293

      

Sources

php show the following code for failing to get SYSVSEM_SETVAL

while (semop(semid, sop, 3) == -1) {
    if (errno != EINTR) {
        php3_error(E_WARNING, "semop() failed acquiring SYSVSEM_SETVAL for key 0x%x: %s", key, strerror(errno));
        break;
    }
}

      

which means semop does not work with EINTR. The man page shows that the semop () system call was interrupted by a signal.

My question is, can I safely ignore this error and repeat sem_acquire?

Edit : I misunderstood this issue, Pl see the explanations I posted below.

Rajah

+1


source to share


2 answers


I wouldn't ignore ENOSPC (you end up with something other than EINTR, as the code shows). You may find yourself in a busy loop waiting for a resource that you previously exhausted. If you are somewhere in the wrong place, you want to make sure that you are dealing with this problem. ENOSPC usually means that you are not ... something.

A few random ideas:



I am not a PHP implementation expert, but I would try to avoid calling sem_get()

every time you want a semaphore. Store your pen instead. There might be some resource associated with each sem_get call and this is where you run out of free space.

I would not check for error returns on sem_get()

. This is a piece of code, but if you fail to get sema4 you will get inconsistent results when you try sem_op()

it (maybe EINTR makes sense)

+1


source


After posting this question, I noticed that I was reading the code incorrectly as and went to the end. As Swamp pointed out, a bug , not a . After some digging, I found the reason . Undo buffers have been depleted. I increased the number and now the code works without issue. I used l as valueerrno

==

EINTR

ENOSPC

EINTR

ENOSPC

semmnu

semmni*semms

semmnu



0


source







All Articles