Fix race condition with getEvent and getEventNonBlocking

It's possible that the buffer was filled while we weren't looking
and thus doesn't need to be filled again.    While this fix avoids
clobbering a buffer of unread events,  there's still some small risk
that getEvent and peekEvent would block for too long under this same
scenario.

Also,  the names of fillBufferBlocking / needLock / haveLock
are rather obsolete and somewhat misleading...