source/Core/Utils.php
protected function _lockFile($sFilePath, $sIdent, $iLockMode = LOCK_EX)
    {
        $rHandle = isset($this->_aLockedFileHandles[$iLockMode][$sIdent]) ? $this->_aLockedFileHandles[$iLockMode][$sIdent] : null;
        if ($rHandle === null) {
            $blLocked = false;
            $rHandle = @fopen($sFilePath, "a+");

            if ($rHandle !== false) {
                if (flock($rHandle, $iLockMode | LOCK_NB)) {
                    if ($iLockMode === LOCK_EX) {
                        // truncate file
                        $blLocked = ftruncate($rHandle, 0);
                    } else {
                        // move to a start position
                        $blLocked = fseek($rHandle, 0) === 0;
                    }
                }

                // on failure - closing and setting false..
                if (!$blLocked) {
                    fclose($rHandle);
                    $rHandle = false;
                }
            }

            // in case system does not support file locking
            if (!$blLocked && $iLockMode === LOCK_EX) {
                // clearing on first call
                if (count($this->_aLockedFileHandles) == 0) {
                    clearstatcache();
                }

                // start a blank file to inform other processes we are dealing with it.
                if (!(file_exists($sFilePath) && !filesize($sFilePath) && abs(time() - filectime($sFilePath) < 40))) {
                    $rHandle = @fopen($sFilePath, "w");
                }
            }

            $this->_aLockedFileHandles[$iLockMode][$sIdent] = $rHandle;
        }

        return $rHandle;
    }
protected function _lockFile($sFilePath, $sIdent, $iLockMode = LOCK_EX)
    {
        $rHandle = isset($this->_aLockedFileHandles[$iLockMode][$sIdent]) ? $this->_aLockedFileHandles[$iLockMode][$sIdent] : null;
        if ($rHandle === null) {
            $blLocked = false;
            $rHandle = @fopen($sFilePath, "a+");

            if ($rHandle !== false) {
                if (flock($rHandle, $iLockMode | LOCK_NB)) {
                    if ($iLockMode === LOCK_EX) {
                        // truncate file
                        $blLocked = ftruncate($rHandle, 0);
                    } else {
                        // move to a start position
                        $blLocked = fseek($rHandle, 0) === 0;
                    }
                }

                // on failure - closing and setting false..
                if (!$blLocked) {
                    fclose($rHandle);
                    $rHandle = false;
                }
            }

            // in case system does not support file locking
            if (!$blLocked && $iLockMode === LOCK_EX) {
                // clearing on first call
                if (count($this->_aLockedFileHandles) == 0) {
                    clearstatcache();
                }

                // start a blank file to inform other processes we are dealing with it.
                if (!(file_exists($sFilePath) && !filesize($sFilePath) && abs(time() - filectime($sFilePath) < 40))) {
                    $rHandle = @fopen($sFilePath, "w");
                }
            }

            $this->_aLockedFileHandles[$iLockMode][$sIdent] = $rHandle;
        }

        return $rHandle;
    }
protected function _lockFile ( $ sFilePath , $ sIdent , $ iLockMode = LOCK_EX ) { $ rHandle = isset ( $ this -> _aLockedFileHandles [ $ iLockMode ] [ $ sIdent ] ) ? $ this -> _aLockedFileHandles [ $ iLockMode ] [ $ sIdent ] : null ; if ( $ rHandle === null ) { $ blLocked = false ; $ rHandle = @ fopen ( $ sFilePath , "a+" ) ; if ( $ rHandle !== false ) { if ( flock ( $ rHandle , $ iLockMode | LOCK_NB ) ) { if ( $ iLockMode === LOCK_EX ) { // truncate file $ blLocked = ftruncate ( $ rHandle , 0 ) ; } else { // move to a start position $ blLocked = fseek ( $ rHandle , 0 ) === 0 ; } } // on failure - closing and setting false.. if ( ! $ blLocked ) { fclose ( $ rHandle ) ; $ rHandle = false ; } } // in case system does not support file locking if ( ! $ blLocked && $ iLockMode === LOCK_EX ) { // clearing on first call if ( count ( $ this -> _aLockedFileHandles ) == 0 ) { clearstatcache ( ) ; } // start a blank file to inform other processes we are dealing with it. if ( ! ( file_exists ( $ sFilePath ) && ! filesize ( $ sFilePath ) && abs ( time ( ) - filectime ( $ sFilePath ) < 40 ) ) ) { $ rHandle = @ fopen ( $ sFilePath , "w" ) ; } } $ this -> _aLockedFileHandles [ $ iLockMode ] [ $ sIdent ] = $ rHandle ; } return $ rHandle ; }
Locks cache file and returns its handle on success or false on failure

@param string $sFilePath name of file to lock
@param string $sIdent    lock identifier
@param int    $iLockMode lock mode - LOCK_EX/LOCK_SH

@return mixed lock file resource or false on error
Locks cache file and returns its handle on success or false on failure