From f3db82fcfe9fab2c0977b4cb900c2e913a325e29 Mon Sep 17 00:00:00 2001 From: "F. Duncanh" Date: Mon, 7 Jul 2025 11:25:54 -0400 Subject: [PATCH] cleanup in httpd.c --- lib/httpd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/httpd.c b/lib/httpd.c index 1d17b99..9a4b990 100644 --- a/lib/httpd.c +++ b/lib/httpd.c @@ -211,17 +211,19 @@ httpd_remove_connection(httpd_t *httpd, http_connection_t *connection) httpd->callbacks.conn_destroy(connection->user_data); connection->user_data = NULL; } - shutdown(connection->socket_fd, SHUT_WR); if (connection->socket_fd) { + shutdown(connection->socket_fd, SHUT_WR); int ret = closesocket(connection->socket_fd); if (ret == -1) { logger_log(httpd->logger, LOGGER_ERR, "httpd error in closesocket (close): %d %s", errno, strerror(errno)); } connection->socket_fd = 0; } - connection->connected = 0; + if (connection->connected) { + connection->connected = 0; + httpd->open_connections--; + } connection->type = CONNECTION_TYPE_UNKNOWN; - httpd->open_connections--; } static int