aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-23 19:10:20 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-24 15:51:28 +0300
commit1ab20f6fb92f1b0a55c37cfc94b3dabfcbd100d4 (patch)
tree3142dcf435d55443a6c5d12f479c587a402e557f
parent9d0ae2e223d9da00b710f0eb797343d2390f64c5 (diff)
downloadlibmicrohttpd-1ab20f6fb92f1b0a55c37cfc94b3dabfcbd100d4.tar.gz
libmicrohttpd-1ab20f6fb92f1b0a55c37cfc94b3dabfcbd100d4.zip
Destroy response when it's not needed.
-rw-r--r--src/microhttpd/connection.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index da762614..e2271bba 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -501,6 +501,7 @@ MHD_connection_close_ (struct MHD_Connection *connection,
501 enum MHD_RequestTerminationCode termination_code) 501 enum MHD_RequestTerminationCode termination_code)
502{ 502{
503 struct MHD_Daemon *daemon; 503 struct MHD_Daemon *daemon;
504 struct MHD_Response * const resp = connection->response;
504 505
505 daemon = connection->daemon; 506 daemon = connection->daemon;
506 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) 507 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
@@ -508,6 +509,11 @@ MHD_connection_close_ (struct MHD_Connection *connection,
508 SHUT_WR); 509 SHUT_WR);
509 connection->state = MHD_CONNECTION_CLOSED; 510 connection->state = MHD_CONNECTION_CLOSED;
510 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; 511 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
512 if (NULL != resp)
513 {
514 connection->response = NULL;
515 MHD_destroy_response (resp);
516 }
511 if ( (NULL != daemon->notify_completed) && 517 if ( (NULL != daemon->notify_completed) &&
512 (MHD_YES == connection->client_aware) ) 518 (MHD_YES == connection->client_aware) )
513 daemon->notify_completed (daemon->notify_completed_cls, 519 daemon->notify_completed (daemon->notify_completed_cls,
@@ -2892,6 +2898,13 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2892 continue; 2898 continue;
2893 } 2899 }
2894 connection->state = MHD_CONNECTION_UPGRADE; 2900 connection->state = MHD_CONNECTION_UPGRADE;
2901 /* Response is not required anymore for this conectnion. */
2902 if (NULL != connection->response)
2903 {
2904 struct MHD_Response * const resp_clr = connection->response;
2905 connection->response = NULL;
2906 MHD_destroy_response (resp_clr);
2907 }
2895 continue; 2908 continue;
2896 } 2909 }
2897 if (MHD_NO != socket_flush_possible (connection)) 2910 if (MHD_NO != socket_flush_possible (connection))