Set waiters flag before checking semaphore's counter, otherwise we might lose a wakeup. Tested on postgresql database server.
Set waiters flag before checking semaphore's counter,
otherwise we might lose a wakeup. Tested on postgresql database server.

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase