aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/helper/ApplicationUtils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-12-16 16:01:32 +0100
committerGitHub <noreply@github.com>2020-12-16 16:01:32 +0100
commitb1d78519a8dd8b43698f76c61d9967ca542a1660 (patch)
tree3e43804b25098126c77afe1986b1ddbd9b0aeb94 /application/helper/ApplicationUtils.php
parent3d5f05052f7f2d26d8c26daed8b23aff360efcb2 (diff)
parent8a6b7e96b7176e03238bbb1bcaa4c8b0c25e6358 (diff)
downloadShaarli-b1d78519a8dd8b43698f76c61d9967ca542a1660.tar.gz
Shaarli-b1d78519a8dd8b43698f76c61d9967ca542a1660.tar.zst
Shaarli-b1d78519a8dd8b43698f76c61d9967ca542a1660.zip
Merge pull request #1652 from ArthurHoaro/fix/failing-mutex
Fix: soft fail if the mutex is not working
Diffstat (limited to 'application/helper/ApplicationUtils.php')
-rw-r--r--application/helper/ApplicationUtils.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/application/helper/ApplicationUtils.php b/application/helper/ApplicationUtils.php
index 212dd8e2..a6c03aae 100644
--- a/application/helper/ApplicationUtils.php
+++ b/application/helper/ApplicationUtils.php
@@ -3,6 +3,8 @@
3namespace Shaarli\Helper; 3namespace Shaarli\Helper;
4 4
5use Exception; 5use Exception;
6use malkusch\lock\exception\LockAcquireException;
7use malkusch\lock\mutex\FlockMutex;
6use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
7 9
8/** 10/**
@@ -252,6 +254,20 @@ class ApplicationUtils
252 return $errors; 254 return $errors;
253 } 255 }
254 256
257 public static function checkDatastoreMutex(): array
258 {
259 $mutex = new FlockMutex(fopen(SHAARLI_MUTEX_FILE, 'r'), 2);
260 try {
261 $mutex->synchronized(function () {
262 return true;
263 });
264 } catch (LockAcquireException $e) {
265 $errors[] = t('Lock can not be acquired on the datastore. You might encounter concurrent access issues.');
266 }
267
268 return $errors ?? [];
269 }
270
255 /** 271 /**
256 * Returns a salted hash representing the current Shaarli version. 272 * Returns a salted hash representing the current Shaarli version.
257 * 273 *