diff --git a/vendor/magento/framework/Lock/Backend/FileLock.php b/vendor/magento/framework/Lock/Backend/FileLock.php index 69ffa04be8e70..37d13b0ea4abd 100644 --- a/vendor/magento/framework/Lock/Backend/FileLock.php +++ b/vendor/magento/framework/Lock/Backend/FileLock.php @@ -7,10 +7,10 @@ namespace Magento\Framework\Lock\Backend; -use Magento\Framework\Lock\LockManagerInterface; -use Magento\Framework\Filesystem\Driver\File as FileDriver; -use Magento\Framework\Exception\RuntimeException; use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\RuntimeException; +use Magento\Framework\Filesystem\Driver\File as FileDriver; +use Magento\Framework\Lock\LockManagerInterface; use Magento\Framework\Phrase; /** @@ -83,8 +83,14 @@ public function __construct(FileDriver $fileDriver, string $path) */ public function lock(string $name, int $timeout = -1): bool { + $lockFile = $this->getLockPath($name); + + // If already held by this process, don't open a second fd on the same file. + if (isset($this->locks[$lockFile])) { + return true; + } + try { - $lockFile = $this->getLockPath($name); $fileResource = $this->fileDriver->fileOpen($lockFile, 'w+'); $skipDeadline = $timeout < 0; $deadline = microtime(true) + $timeout;