dri*_*tan 8 php semaphore ipcs
我正在使用信号量来同步我的应用程序中的某些部分.
在释放信号量(sem_release)时,我收到此警告:
sem_release():无法释放密钥0xc:无效的参数
首先我不知道信号量是否被释放,但由于我没有得到"真实"的结果,我猜它不会释放.
PHP版本:5.6.30
ipcs -V =>来自util-linux 2.25.2的ipcs
这是信号量:
key semid owner perms nsems
0x0000000c 4124122 myUser 666 3
Run Code Online (Sandbox Code Playgroud)
这是代码的一部分(类Synchronization):
...
if ( !( $this->semaphoreId = sem_get( $this->id, 1 ) ) )
throw new RuntimeException( 'Error getting Semaphore.');
...
if ( !sem_acquire( $this->semaphoreId ) )
throw new RuntimeException( 'Error acquiring Semaphore.');
...
if ( !sem_release( $this->semaphoreId ) )
throw new RuntimeException( 'Error releasing Semaphore.');
Run Code Online (Sandbox Code Playgroud)
PS我只是在我的生产环境中得到这个错误,而且我无法在我的测试环境中重现/调试.
我在互联网上搜索了这条错误信息,但我一无所获.
有谁知道这个消息是什么意思?
编辑:
小智 1
您能否从头开始执行以下步骤:
resource sem_get ( int $key [, int $max_acquire = 1 [, int $perm = 0666 [, int $auto_release = 1 ]]] )
bool sem_acquire ( resource $sem_identifier [, bool $nowait = false ] )并添加健全性检查以确保上述函数返回预期值。
您还可以检查应用程序的其他部分是否在同一用户下运行,以避免权限问题。