diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-26 14:18:01 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:38:19 +0200 |
commit | fd1ddad98df45bc3c18be7980c1cbe68ce6b219c (patch) | |
tree | e4017d3c979604f40e78cdc305f0ab191aedd4b9 /application/api | |
parent | 458b6b9918ec27154dd45416947bb93bedb97109 (diff) | |
download | Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.tar.gz Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.tar.zst Shaarli-fd1ddad98df45bc3c18be7980c1cbe68ce6b219c.zip |
Add mutex on datastore I/O operations
To make sure that there is no concurrent operation on the datastore file.
Fixes #1132
Diffstat (limited to 'application/api')
-rw-r--r-- | application/api/ApiMiddleware.php | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/application/api/ApiMiddleware.php b/application/api/ApiMiddleware.php index f5b53b01..adc8b266 100644 --- a/application/api/ApiMiddleware.php +++ b/application/api/ApiMiddleware.php | |||
@@ -1,6 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Api; | 2 | namespace Shaarli\Api; |
3 | 3 | ||
4 | use malkusch\lock\mutex\FlockMutex; | ||
4 | use Shaarli\Api\Exceptions\ApiAuthorizationException; | 5 | use Shaarli\Api\Exceptions\ApiAuthorizationException; |
5 | use Shaarli\Api\Exceptions\ApiException; | 6 | use Shaarli\Api\Exceptions\ApiException; |
6 | use Shaarli\Bookmark\BookmarkFileService; | 7 | use Shaarli\Bookmark\BookmarkFileService; |
@@ -143,6 +144,7 @@ class ApiMiddleware | |||
143 | $linkDb = new BookmarkFileService( | 144 | $linkDb = new BookmarkFileService( |
144 | $conf, | 145 | $conf, |
145 | $this->container->get('history'), | 146 | $this->container->get('history'), |
147 | new FlockMutex(fopen(SHAARLI_MUTEX_FILE, 'r'), 2), | ||
146 | true | 148 | true |
147 | ); | 149 | ); |
148 | $this->container['db'] = $linkDb; | 150 | $this->container['db'] = $linkDb; |