core/epgsql: more improvements to connection handling.

This continues the changes started in commit 2480faf993b9fdd50fbfbeec7813b2ccde34588b.

When a new connection is reqeusted from the db pool, it will only put
the client on the waiting queue in case of errors if there already are
other successfull connections.