Fixed a race condition in MessageLock.