From 60d4b0605714a3ff3c33651e821fde22e2b7100c Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 27 Feb 2025 08:52:42 -0500 Subject: [PATCH] http: Prevent reentering tf_http_destroy. --- src/http.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/http.c b/src/http.c index 86e545d1..fbf656b4 100644 --- a/src/http.c +++ b/src/http.c @@ -84,6 +84,7 @@ typedef struct _tf_http_listener_t typedef struct _tf_http_t { bool is_shutting_down; + bool is_in_destroy; tf_http_listener_t** listeners; int listeners_count; @@ -786,7 +787,13 @@ static void _http_free_listener_on_close(uv_handle_t* handle) void tf_http_destroy(tf_http_t* http) { + if (http->is_in_destroy) + { + return; + } + http->is_shutting_down = true; + http->is_in_destroy = true; for (int i = 0; i < http->connections_count; i++) { @@ -845,6 +852,10 @@ void tf_http_destroy(tf_http_t* http) tf_free(http); } + else + { + http->is_in_destroy = false; + } } const char* tf_http_status_text(int status)