https: drain HTTP/2 output queue if possible
The underlying TCP socket is mostly used for receiving. So in most cases, there is enough space in send buffers for the final packets (such as RST_STREAM and GOAWAY frames). This fixes a race condition where the output thread got cancelled before draining the queue. Now, it only gets cancelled if the send buffer is congested (i.e. it calls poll(POLLOUT)). In normal cases, the thread will exit explicitly after draining.
Showing with 39 additions and 24 deletions