From 4deb335de8af6cc943ca7fc20a69167d8845cd9b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 10 Mar 2017 16:29:58 +0100 Subject: [PATCH] avoid redundant NULL check, make MHD_cleanup_upgraded_connection_ static (only used from within daemon.c) and rename to cleanup_upgraded_connection --- src/microhttpd/daemon.c | 14 +++++++------- src/microhttpd/internal.h | 12 ------------ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 3499f211..9dd2f1cd 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -1121,11 +1121,13 @@ call_handlers (struct MHD_Connection *con, * * @param connection handle to the upgraded connection to clean */ -void -MHD_cleanup_upgraded_connection_ (struct MHD_Connection *connection) +static void +cleanup_upgraded_connection (struct MHD_Connection *connection) { struct MHD_UpgradeResponseHandle *urh = connection->urh; + if (NULL == urh) + return; #ifdef HTTPS_SUPPORT /* Signal remote client the end of TLS connection by * gracefully closing TLS session. */ @@ -1139,13 +1141,12 @@ MHD_cleanup_upgraded_connection_ (struct MHD_Connection *connection) if (MHD_INVALID_SOCKET != urh->app.socket) MHD_socket_close_chk_ (urh->app.socket); #endif /* HTTPS_SUPPORT */ - connection->urh = NULL; - if (NULL != urh) - free (urh); + free (urh); } #endif /* UPGRADE_SUPPORT */ + #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) /** * Performs bi-directional forwarding on upgraded HTTPS connections @@ -2982,8 +2983,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) (! MHD_join_thread_ (pos->pid)) ) MHD_PANIC (_("Failed to join a thread\n")); #ifdef UPGRADE_SUPPORT - if (NULL != pos->urh) - MHD_cleanup_upgraded_connection_ (pos); + cleanup_upgraded_connection (pos); #endif /* UPGRADE_SUPPORT */ MHD_pool_destroy (pos->pool); #ifdef HTTPS_SUPPORT diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 4979474b..efe3fbb8 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h @@ -1800,16 +1800,4 @@ MHD_parse_arguments_ (struct MHD_Connection *connection, unsigned int *num_headers); -#ifdef UPGRADE_SUPPORT -/** - * Finally cleanup upgrade-related resources. It should - * be called when TLS buffers have been drained and - * application signaled MHD by #MHD_UPGRADE_ACTION_CLOSE. - * - * @param connection handle to the upgraded connection to clean - */ -void -MHD_cleanup_upgraded_connection_ (struct MHD_Connection *connection); -#endif /* UPGRADE_SUPPORT */ - #endif