mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Include COUNT in lock and make RND per-process incase randomBytes blocks
This commit is contained in:
parent
d15a22be26
commit
4ab4e27724
1 changed files with 3 additions and 2 deletions
|
@ -9,6 +9,8 @@ crypto = require "crypto"
|
||||||
|
|
||||||
HOST = os.hostname()
|
HOST = os.hostname()
|
||||||
PID = process.pid
|
PID = process.pid
|
||||||
|
RND = crypto.randomBytes(4).toString('hex')
|
||||||
|
COUNT = 0
|
||||||
|
|
||||||
module.exports = LockManager =
|
module.exports = LockManager =
|
||||||
LOCK_TEST_INTERVAL: 50 # 50ms between each test of the lock
|
LOCK_TEST_INTERVAL: 50 # 50ms between each test of the lock
|
||||||
|
@ -20,8 +22,7 @@ module.exports = LockManager =
|
||||||
# to prevent accidental unlocking by multiple processes
|
# to prevent accidental unlocking by multiple processes
|
||||||
randomLock : () ->
|
randomLock : () ->
|
||||||
time = Date.now()
|
time = Date.now()
|
||||||
RND = crypto.randomBytes(4).toString('hex')
|
return "locked:host=#{HOST}:pid=#{PID}:random=#{RND}:time=#{time}:count=#{COUNT++}"
|
||||||
return "locked:host=#{HOST}:pid=#{PID}:random=#{RND}:time=#{time}"
|
|
||||||
|
|
||||||
unlockScript: 'if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end';
|
unlockScript: 'if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue