0

このエラーが発生しています

Call to undefined function sem_get()

PHP バージョン 5.3.27、Apache/2.2.15、および CentOS で実行されています。

この理由を見つけることができません。また、(ほぼ) 同じセットアップのテスト サーバーがあり、正常に動作しています (このサーバーを他のプロジェクトでも使用しているため、PHP 拡張機能が異なる可能性があります)。

私が実行しているテストは次のとおりです。

<pre>
starts
<?
try {

    echo "instance\n";
    $mutex = new Mutex(633);
    echo "Acquire \n";
    $mutex->Acquire();
    echo "\n\n Atomic magic \n\n";
    echo "release \n";
    $mutex->Release();
    echo "null \n";
    $mutex = null;
    echo "end \n";

}
catch (Exception $e)
{
    echo $e;
    echo "\n<hr>\n";
    var_dump(error_get_last()); 
}

クラス Mutex は次のとおりです。

<?php
class Mutex
{
    protected $_Id;
    protected $_SemId;
    protected $_IsAcquired = false;

    /**
     * @param int $id Identifier of the Mutex, must be a number
     */
    function __construct($id)
    {
        if (!is_int($id))
        {
            throw new Exception('The Mutex identifier must be a number');
        }

        $this->_Id = $id;

        if (!($this->_SemId = sem_get($this->_Id, 1)))
        {
            throw new Exception('Error getting semaphore');
        }

    }

    public function Acquire()
    {
        if (!sem_acquire($this->_SemId))
        {
            throw new Exception('Error acquiring semaphore');
        }

        $this->_IsAcquired = true;
    }

    public function Release()
    {
        if (!$this->_IsAcquired)
        {
            return;
        }

        if (!sem_release($this->_SemId))
        {
            throw new Exception('Error releasing semaphore');
        }

        $this->_IsAcquired = false;
    }
}
?>

ありがとう

4

0 に答える 0