commit 730134054bb94b499adf4164c29d5346ff1fdec1 parent 243e8fcd6054e4c0d2964b0d4b29e0c15861498d Author: Evgeny Grin (Karlson2k) <k2k@narod.ru> Date: Mon, 5 Jun 2017 21:00:39 +0300 Replace usage of MHD_Connection::tls_closed with MHD_Connection::tls_state Diffstat:
| M | src/microhttpd/connection_https.c | | | 21 | +++++++++++++++++---- |
| M | src/microhttpd/internal.h | | | 5 | ----- |
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c @@ -246,12 +246,25 @@ MHD_set_https_callbacks (struct MHD_Connection *connection) bool MHD_tls_connection_shutdown (struct MHD_Connection *connection) { - if (! connection->tls_closed) + if (MHD_TLS_CONN_WR_CLOSED > connection->tls_state) { - connection->tls_closed = - (GNUTLS_E_SUCCESS == gnutls_bye(connection->tls_session, GNUTLS_SHUT_WR)); + const int res = + gnutls_bye(connection->tls_session, GNUTLS_SHUT_WR); + if (GNUTLS_E_SUCCESS == ret) + { + connection->tls_state = MHD_TLS_CONN_WR_CLOSED; + return true; + } + if ((GNUTLS_E_AGAIN == ret) || + (GNUTLS_E_INTERRUPTED == ret)) + { + connection->tls_state = MHD_TLS_CONN_WR_CLOSING; + return true; + } + else + connection->tls_state = MHD_TLS_CONN_TLS_FAILED; } - return connection->tls_closed ? MHD_YES : MHD_NO;; + return false; } /* end of connection_https.c */ diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -989,11 +989,6 @@ struct MHD_Connection * even though the socket is not? */ bool tls_read_ready; - - /** - * TLS layer was shut down? - */ - bool tls_closed; #endif /* HTTPS_SUPPORT */ /**