Clear OpenSSL's error queue before using it
Clear OpenSSL's error queue before using it

From SSL_get_error(3ssl):

 The current thread's error queue must be empty before the TLS/SSL I/O
 operation is attempted, or SSL_get_error() will not work reliably.

There are a couple of locations where H2O relies on SSL_get_error(),
especially to check if a read operation would block. As of OpenSSL 1.1,
if there is any error in the current thread's error queue, it will mask
SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE in SSL_get_error()'s return
values. IOW, if an error occurs during an SSL_write() call, a subsequent
SSL_get_error() call after a would-block SSL_read() call will return the
former error instead of SSL_ERROR_WANT_READ. As this is happening inside
a tight event loop, the SSL_write() and SSL_read() calls could refer to
different connections, propagating errors from one connection to the
other one.

Fix this by making sure the error queue is cleared right before the I/O
call whose result we want to check.

cwyang/h2o,lkwg82/h2o,yannick/h2o,yannick/h2o,deweerdt/h2o,lkwg82/h2o,cwyang/h2o,h2o/h2o,cwyang/h2o,yannick/h2o,h2o/h2o,deweerdt/h2o,cwyang/h2o,deweerdt/h2o,zlm2012/h2o,cwyang/h2o,deweerdt/h2o,deweerdt/h2o,zlm2012/h2o,devnexen/h2o,lkwg82/h2o,deweerdt/h2o,cwyang/h2o,h2o/h2o,devnexen/h2o,lkwg82/h2o,deweerdt/h2o,yannick/h2o,devnexen/h2o,cwyang/h2o,zlm2012/h2o,lkwg82/h2o,h2o/h2o,zlm2012/h2o,h2o/h2o,yannick/h2o,zlm2012/h2o,cwyang/h2o,devnexen/h2o,devnexen/h2o,lkwg82/h2o,deweerdt/h2o,devnexen/h2o,yannick/h2o,devnexen/h2o,lkwg82/h2o,deweerdt/h2o,h2o/h2o,yannick/h2o,zlm2012/h2o,lkwg82/h2o,yannick/h2o,devnexen/h2o,yannick/h2o,zlm2012/h2o,h2o/h2o,lkwg82/h2o,h2o/h2o,h2o/h2o,zlm2012/h2o,zlm2012/h2o,devnexen/h2o