clean up TLS and HTTP data correctly

we don't want to call isc__nm_http_cleanup_data() for TLS sockets
or isc__nm_tls_cleanup_data() for HTTP sockets, they can step on
each other and cause a crash or deadlock.
This commit is contained in:
Evan Hunt
2021-02-09 12:57:26 -08:00
parent 662197d5c2
commit e6d35ea0e8
2 changed files with 10 additions and 1 deletions

View File

@@ -1903,7 +1903,7 @@ clear_handlers(isc_nmsocket_t *sock) {
static void
clear_session(isc_nmsocket_t *sock) {
if (sock->type != isc_nm_httpsocket && sock->h2.session != NULL) {
if (sock->h2.session != NULL) {
isc_nm_http_session_t *session = sock->h2.session;
INSIST(ISC_LIST_EMPTY(session->sstreams));
delete_http_session(session);
@@ -2221,6 +2221,11 @@ isc__nm_http_initsocket(isc_nmsocket_t *sock) {
void
isc__nm_http_cleanup_data(isc_nmsocket_t *sock) {
if (sock->type != isc_nm_httplistener &&
sock->type != isc_nm_httpsocket) {
return;
}
if (sock->type == isc_nm_httplistener) {
clear_handlers(sock);
isc_rwlock_destroy(&sock->h2.lock);

View File

@@ -946,6 +946,10 @@ isc__nm_async_tlsdobio(isc__networker_t *worker, isc__netievent_t *ev0) {
void
isc__nm_tls_cleanup_data(isc_nmsocket_t *sock) {
if (sock->type != isc_nm_tlslistener && sock->type != isc_nm_tlssocket)
{
return;
}
if (sock->tlsstream.tlslistener != NULL) {
REQUIRE(VALID_NMSOCK(sock->tlsstream.tlslistener));
isc__nmsocket_detach(&sock->tlsstream.tlslistener);