De-uglify state transitions

Let the state transition functions take a mutex and condition variable
so we don't have to worry about the case where completion can be
signalled from the transition function causing deadlock.

This allows us to not spawn a thread for the completion procedure.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>