src: Fix assertion error with boringssl

boringssl says:

/* It is an error to clear any bits that have already been set. (We can't try
 * to get a second close_notify or send two.) */
assert((SSL_get_shutdown(ssl) & mode) == SSL_get_shutdown(ssl));
This commit is contained in:
Tatsuhiro Tsujikawa 2017-01-02 11:48:38 +09:00
parent 2b6073900f
commit 3933280d29
4 changed files with 5 additions and 4 deletions

View File

@ -557,7 +557,7 @@ Http2Handler::~Http2Handler() {
on_session_closed(this, session_id_); on_session_closed(this, session_id_);
nghttp2_session_del(session_); nghttp2_session_del(session_);
if (ssl_) { if (ssl_) {
SSL_set_shutdown(ssl_, SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(ssl_, SSL_get_shutdown(ssl_) | SSL_RECEIVED_SHUTDOWN);
ERR_clear_error(); ERR_clear_error();
SSL_shutdown(ssl_); SSL_shutdown(ssl_);
} }

View File

@ -509,7 +509,7 @@ void Client::disconnect() {
ev_io_stop(worker->loop, &wev); ev_io_stop(worker->loop, &wev);
ev_io_stop(worker->loop, &rev); ev_io_stop(worker->loop, &rev);
if (ssl) { if (ssl) {
SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(ssl, SSL_get_shutdown(ssl) | SSL_RECEIVED_SHUTDOWN);
ERR_clear_error(); ERR_clear_error();
if (SSL_shutdown(ssl) != 1) { if (SSL_shutdown(ssl) != 1) {

View File

@ -701,7 +701,7 @@ void HttpClient::disconnect() {
session = nullptr; session = nullptr;
if (ssl) { if (ssl) {
SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(ssl, SSL_get_shutdown(ssl) | SSL_RECEIVED_SHUTDOWN);
ERR_clear_error(); ERR_clear_error();
SSL_shutdown(ssl); SSL_shutdown(ssl);
SSL_free(ssl); SSL_free(ssl);

View File

@ -95,7 +95,8 @@ Connection::~Connection() { disconnect(); }
void Connection::disconnect() { void Connection::disconnect() {
if (tls.ssl) { if (tls.ssl) {
SSL_set_shutdown(tls.ssl, SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown(tls.ssl,
SSL_get_shutdown(tls.ssl) | SSL_RECEIVED_SHUTDOWN);
ERR_clear_error(); ERR_clear_error();
if (tls.cached_session) { if (tls.cached_session) {