Closed pomarec closed 12 years ago
Thanks for the pull request, @pomarec. For some reason, Github didn't give me notifications about your pull request, or else I would have merged it earlier. Thanks a ton!
@pomarec I realise I'm asking for a bit much, but can you also provide a test that demonstrates how it was broken before your patch? It'll be a huge help.
I'm sorry to tell you that I could not write a good test for this issue. This is what I came up with but I can't make it "bug".
it("shouldn't delay the second operation longer than the timeout value (100ms)", function(done) {
var start = new Date();
lock("testLock", 100, function(completed) {
var lockDate = new Date().getTime();
lock("testLock", 100, function(completed2) {
var unlockDate = new Date().getTime();
(unlockDate - lockDate).should.be.below(5000);
completed2();
done();
});
completed();
});
});
Ignore the last message Brain fart.
If another client del the key between setnx and get, it triggered a wait of lockTimeout seconds, not anymore.