Go to the documentation of this file.
39 self::LOCK_SH => self::LOCK_SH,
40 self::LOCK_UW => self::LOCK_SH,
41 self::LOCK_EX => self::LOCK_EX
56 parent::__construct( $config );
58 $this->lockDir = $config[
'lockDirectory'];
70 $lockedPaths =
array();
73 if ( $status->isOK() ) {
74 $lockedPaths[] =
$path;
112 if ( isset( $this->locksHeld[
$path][
$type] ) ) {
114 } elseif ( isset( $this->locksHeld[
$path][self::LOCK_EX] ) ) {
117 if ( isset( $this->handles[
$path] ) ) {
118 $handle = $this->handles[
$path];
121 $handle = fopen( $this->
getLockPath( $path ),
'a+' );
125 $handle = fopen( $this->
getLockPath( $path ),
'a+' );
131 if ( flock( $handle, $lock | LOCK_NB ) ) {
134 $this->handles[
$path] = $handle;
137 $status->fatal(
'lockmanager-fail-acquirelock',
$path );
140 $status->fatal(
'lockmanager-fail-openlock',
$path );
157 if ( !isset( $this->locksHeld[
$path] ) ) {
158 $status->warning(
'lockmanager-notlocked',
$path );
159 } elseif ( !isset( $this->locksHeld[
$path][
$type] ) ) {
160 $status->warning(
'lockmanager-notlocked',
$path );
162 $handlesToClose =
array();
167 if ( !count( $this->locksHeld[
$path] ) ) {
168 unset( $this->locksHeld[
$path] );
169 if ( isset( $this->handles[
$path] ) ) {
170 $handlesToClose[] = $this->handles[
$path];
171 unset( $this->handles[
$path] );
199 foreach ( $handlesToClose
as $handle ) {
200 if ( !flock( $handle, LOCK_UN ) ) {
201 $status->fatal(
'lockmanager-fail-releaselock',
$path );
203 if ( !fclose( $handle ) ) {
204 $status->warning(
'lockmanager-fail-closelock',
$path );
217 if ( !isset( $this->locksHeld[
$path] ) ) {
218 # No locks are held for the lock file anymore
220 $status->warning(
'lockmanager-fail-deletelock',
$path );
222 unset( $this->handles[
$path] );
234 return "{$this->lockDir}/{$this->sha1Base36Absolute( $path )}.lock";
241 while ( count( $this->locksHeld ) ) {
242 foreach ( $this->locksHeld
as $path => $locks ) {
Class for handling resource locking.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Simple version of LockManager based on using FS lock files.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
const LOCK_SH
Lock types; stronger locks have higher values.
getLockPath( $path)
Get the path to the lock file for a key.
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
pruneKeyLockFiles( $path)
static newGood( $value=null)
Factory function for good results.
__construct(array $config)
Construct a new instance from configuration.
array $handles
Map of (locked key => lock file handle) *.
wfRestoreWarnings()
Restore error level to previous value.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
array $lockTypeMap
Mapping of lock types to the type actually used *.
doSingleUnlock( $path, $type)
Unlock a single resource key.
wfIsWindows()
Check if the operating system is Windows.
doSingleLock( $path, $type)
Lock a single resource key.
doUnlock(array $paths, $type)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
doLock(array $paths, $type)
__destruct()
Make sure remaining locks get cleared for sanity.
closeLockHandles( $path, array $handlesToClose)