From a0e5c46d5f0e5d9cdb920a6cfdbeaf68cc24df94 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 21 Dec 2011 10:06:47 +0000 Subject: [PATCH] Optimized doOperations() a bit to only get SH locks for the paths that aren't already going to get EX locks --- includes/filerepo/backend/FileBackend.php | 2 ++ includes/filerepo/backend/FileBackendMultiWrite.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/includes/filerepo/backend/FileBackend.php b/includes/filerepo/backend/FileBackend.php index 4b260e6d33..694e231e91 100644 --- a/includes/filerepo/backend/FileBackend.php +++ b/includes/filerepo/backend/FileBackend.php @@ -743,6 +743,8 @@ abstract class FileBackend extends FileBackendBase { $filesLockSh = array_merge( $filesLockSh, $fileOp->storagePathsRead() ); $filesLockEx = array_merge( $filesLockEx, $fileOp->storagePathsChanged() ); } + // Optimization: if doing an EX lock anyway, don't also set an SH one + $filesLockSh = array_diff( $filesLockSh, $filesLockEx ); // Try to lock those files for the scope of this function... $scopeLockS = $this->getScopedFileLocks( $filesLockSh, LockManager::LOCK_UW, $status ); $scopeLockE = $this->getScopedFileLocks( $filesLockEx, LockManager::LOCK_EX, $status ); diff --git a/includes/filerepo/backend/FileBackendMultiWrite.php b/includes/filerepo/backend/FileBackendMultiWrite.php index e361ed22c5..c73dcca454 100644 --- a/includes/filerepo/backend/FileBackendMultiWrite.php +++ b/includes/filerepo/backend/FileBackendMultiWrite.php @@ -82,6 +82,8 @@ class FileBackendMultiWrite extends FileBackendBase { $filesLockSh = array_merge( $filesLockSh, $fileOp->storagePathsRead() ); $filesLockEx = array_merge( $filesLockEx, $fileOp->storagePathsChanged() ); } + // Optimization: if doing an EX lock anyway, don't also set an SH one + $filesLockSh = array_diff( $filesLockSh, $filesLockEx ); // Lock the paths under the proxy backend's name $this->unsubstPaths( $filesLockSh ); $this->unsubstPaths( $filesLockEx ); -- 2.20.1