Add state query methods, protect with `Mutex` lock

This adds query methods for a server's "state". These are used
internally by the `Server` class but are also available as public
methods for querying the server's state. This also adds mutex
locking for the state. This is done because it's a common
practice for multiple threads to read/modify the the state via
the commands and query methods. This is also true via signal
trapping which can modify the state. This is a more robust
implementation of the internal "state" of the server that was
pulled from `Qs`.