Have we achieved clean shutdown?

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4841 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-02-13 23:07:36 +00:00
parent e7791d38ff
commit 685754895b
6 changed files with 84 additions and 75 deletions

View File

@ -702,6 +702,31 @@ void tf_http_destroy(tf_http_t* http)
_http_connection_destroy(http->connections[i], "tf_http_destroy");
}
for (int i = 0; i < http->listeners_count; i++)
{
tf_http_listener_t* listener = http->listeners[i];
if (listener->cleanup)
{
listener->cleanup(listener->user_data);
listener->cleanup = NULL;
}
}
for (int i = 0; i < http->handlers_count; i++)
{
if (http->handlers[i].cleanup)
{
http->handlers[i].cleanup(http->handlers[i].user_data);
http->handlers[i].cleanup = NULL;
}
}
if (http->user_data_cleanup)
{
http->user_data_cleanup(http->user_data);
http->user_data = NULL;
}
if (http->connections_count == 0)
{
tf_free(http->connections);
@ -710,10 +735,6 @@ void tf_http_destroy(tf_http_t* http)
for (int i = 0; i < http->listeners_count; i++)
{
tf_http_listener_t* listener = http->listeners[i];
if (listener->cleanup)
{
listener->cleanup(listener->user_data);
}
uv_close((uv_handle_t*)&listener->tcp, _http_free_listener_on_close);
}
tf_free(http->listeners);
@ -727,20 +748,10 @@ void tf_http_destroy(tf_http_t* http)
tf_free((void*)http->handlers[i].pattern);
http->handlers[i].pattern = NULL;
}
if (http->handlers[i].cleanup)
{
http->handlers[i].cleanup(http->handlers[i].user_data);
}
}
tf_free(http->handlers);
http->handlers_count = 0;
if (http->user_data_cleanup)
{
http->user_data_cleanup(http->user_data);
http->user_data = NULL;
}
tf_free(http);
}
}