http: Prevent reentering tf_http_destroy.

This commit is contained in:
Cory McWilliams 2025-02-27 08:52:42 -05:00
parent 4c3df34950
commit 60d4b06057

View File

@ -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)