Fixed race in the lock method

if setnx failed and the following get returns nil, it means that the
lock just got unlocked. It's very unlikely race, but it happens.
This patch change this behavior to redo a setnx if the following get
is nil.