Skip to content

Commit

Permalink
Force RedLockMutex::extend_lock() to return -1ms on failure. (#39)
Browse files Browse the repository at this point in the history
This is done by checking if the flag that
RedLockMutexVessel::extend_lock() returns. If false, the lock failed
and -1ms is returned.
  • Loading branch information
wingunder authored and sewenew committed Nov 20, 2019
1 parent 10c333d commit 217b582
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sw/redis++/recipes/redlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ class RedLockMutex
const RedLockMutexVessel::LockInfo lock_info =
{true, std::chrono::steady_clock::now(), ttl, _resource, random_string};
const auto result = _redlock_mutex.extend_lock(lock_info, ttl);
return result.time_remaining;
if (!result.locked) {
return std::chrono::milliseconds(-1);
}
else {
return result.time_remaining;
}
}

std::chrono::milliseconds extend_lock(const std::string &random_string,
Expand Down

0 comments on commit 217b582

Please sign in to comment.