From 3933280d29576e64e5e1bcaf76af15a48903b662 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 2 Jan 2017 11:48:38 +0900 Subject: [PATCH] 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)); --- src/HttpServer.cc | 2 +- src/h2load.cc | 2 +- src/nghttp.cc | 2 +- src/shrpx_connection.cc | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 272a42df..f4dec3c5 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -557,7 +557,7 @@ Http2Handler::~Http2Handler() { on_session_closed(this, session_id_); nghttp2_session_del(session_); if (ssl_) { - SSL_set_shutdown(ssl_, SSL_RECEIVED_SHUTDOWN); + SSL_set_shutdown(ssl_, SSL_get_shutdown(ssl_) | SSL_RECEIVED_SHUTDOWN); ERR_clear_error(); SSL_shutdown(ssl_); } diff --git a/src/h2load.cc b/src/h2load.cc index 88ec7299..59917eac 100644 --- a/src/h2load.cc +++ b/src/h2load.cc @@ -509,7 +509,7 @@ void Client::disconnect() { ev_io_stop(worker->loop, &wev); ev_io_stop(worker->loop, &rev); if (ssl) { - SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN); + SSL_set_shutdown(ssl, SSL_get_shutdown(ssl) | SSL_RECEIVED_SHUTDOWN); ERR_clear_error(); if (SSL_shutdown(ssl) != 1) { diff --git a/src/nghttp.cc b/src/nghttp.cc index 02ff2111..12f7d362 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -701,7 +701,7 @@ void HttpClient::disconnect() { session = nullptr; if (ssl) { - SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN); + SSL_set_shutdown(ssl, SSL_get_shutdown(ssl) | SSL_RECEIVED_SHUTDOWN); ERR_clear_error(); SSL_shutdown(ssl); SSL_free(ssl); diff --git a/src/shrpx_connection.cc b/src/shrpx_connection.cc index 80d97e85..a10f4358 100644 --- a/src/shrpx_connection.cc +++ b/src/shrpx_connection.cc @@ -95,7 +95,8 @@ Connection::~Connection() { disconnect(); } void Connection::disconnect() { 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(); if (tls.cached_session) {