Obtain lock once before giving up if 0 passed as timeout. Fix #12