dispatch_connection: only read when we need more data

Try to avoid reading if we don't need data, such that we can directly
act on the return code of the read, that is, if we read when we need to
read and that results in EOF or error, we can disconnect right away,
because there is nothing we can do any more (in contrast to before where
we might have data in the buffer that could be processed still).