Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
49ad0fcf
Commit
49ad0fcf
authored
Apr 29, 2016
by
Robin Appelman
Browse files
optimize releaselock for memcache based locking backends
parent
5b45f0f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/Lock/AbstractLockingProvider.php
View file @
49ad0fcf
...
...
@@ -116,4 +116,8 @@ abstract class AbstractLockingProvider implements ILockingProvider {
$this
->
releaseLock
(
$path
,
self
::
LOCK_EXCLUSIVE
);
}
}
protected
function
getOwnSharedLockCount
(
$path
)
{
return
isset
(
$this
->
acquiredLocks
[
'shared'
][
$path
])
?
$this
->
acquiredLocks
[
'shared'
][
$path
]
:
0
;
}
}
lib/private/Lock/MemcacheLockingProvider.php
View file @
49ad0fcf
...
...
@@ -88,9 +88,14 @@ class MemcacheLockingProvider extends AbstractLockingProvider {
*/
public
function
releaseLock
(
$path
,
$type
)
{
if
(
$type
===
self
::
LOCK_SHARED
)
{
if
(
isset
(
$this
->
acquiredLocks
[
'shared'
][
$path
])
and
$this
->
acquiredLocks
[
'shared'
][
$path
]
>
0
)
{
if
(
$this
->
getOwnSharedLockCount
(
$path
)
===
1
)
{
$removed
=
$this
->
memcache
->
cad
(
$path
,
1
);
// if we're the only one having a shared lock we can remove it in one go
if
(
!
$removed
)
{
//someone else also has a shared lock, decrease only
$this
->
memcache
->
dec
(
$path
);
}
}
else
{
// if we own more than one lock ourselves just decrease
$this
->
memcache
->
dec
(
$path
);
$this
->
memcache
->
cad
(
$path
,
0
);
}
}
else
if
(
$type
===
self
::
LOCK_EXCLUSIVE
)
{
$this
->
memcache
->
cad
(
$path
,
'exclusive'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment