apiserver: fix increment of waitgroup count after wait
apiserver: fix increment of waitgroup count after wait

Fixes LP 1588143

This changes fixes a bug whereby the count of requests in fly could be
incremented after a call to wg.Wait() is issued. The contract for
wg.Wait says that once this function has been called, only calls to
wg.Done, that is deincrement, may be used.

The shutdown logic for the apiserver is now:

1. wait for srv.tomb.Dying to return.
2. close srv.listner.
3. wait for srv.wg.Wait to reach zero, implying the mongopinger has
   exited and all in fly requests have completed.

Additionally, when a request is received in the short period between the
kill of srv.tomb and the close of srv.listener, return a proper 503
response rather than just leaving the client hanging with no response.

anastasiamac/juju,waigani/juju,gabriel-samfira/juju,marcmolla/juju,axw/juju,reedobrien/juju,dimitern/juju,alesstimec/juju,mikemccracken/juju,gabriel-samfira/juju,ericsnowcurrently/juju,alesstimec/juju,marcmolla/juju,frankban/juju,anastasiamac/juju,mjs/juju,dooferlad/juju,kat-co/juju,dimitern/juju,frankban/juju,axw/juju,bz2/juju,gabriel-samfira/juju,reedobrien/juju,kat-co/juju,kat-co/juju,dooferlad/juju,mjs/juju,mikemccracken/juju,anastasiamac/juju,howbazaar/juju,alesstimec/juju,AdamIsrael/juju,gabriel-samfira/juju,mikemccracken/juju,bac/juju,dimitern/juju,bac/juju,dooferlad/juju,ericsnowcurrently/juju,bz2/juju,AdamIsrael/juju,reedobrien/juju,mjs/juju,macgreagoir/juju,AdamIsrael/juju,bz2/juju,howbazaar/juju,axw/juju,macgreagoir/juju,howbazaar/juju,mjs/juju,dooferlad/juju,anastasiamac/juju,mikemccracken/juju,reedobrien/juju,bz2/juju,bac/juju,waigani/juju,marcmolla/juju,ericsnowcurrently/juju,ericsnowcurrently/juju,frankban/juju,kat-co/juju,dimitern/juju,mjs/juju,axw/juju,bz2/juju,perrito666/juju,dooferlad/juju,axw/juju,macgreagoir/juju,waigani/juju,mjs/juju,reedobrien/juju,ericsnowcurrently/juju,waigani/juju,macgreagoir/juju,dimitern/juju,perrito666/juju,anastasiamac/juju,mjs/juju,bac/juju,frankban/juju,howbazaar/juju,frankban/juju,marcmolla/juju,marcmolla/juju,perrito666/juju,kat-co/juju,alesstimec/juju,perrito666/juju,bac/juju,AdamIsrael/juju,howbazaar/juju,macgreagoir/juju,alesstimec/juju,gabriel-samfira/juju,perrito666/juju,mikemccracken/juju