forked from cory/tildefriends
Continuing the fight against http lifetime issues.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4840 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
9f14653001
commit
e7791d38ff
28
src/http.c
28
src/http.c
@ -83,6 +83,8 @@ typedef struct _tf_http_listener_t
|
||||
|
||||
typedef struct _tf_http_t
|
||||
{
|
||||
bool is_shutting_down;
|
||||
|
||||
tf_http_listener_t** listeners;
|
||||
int listeners_count;
|
||||
|
||||
@ -208,6 +210,12 @@ static void _http_connection_destroy(tf_http_connection_t* connection, const cha
|
||||
connection->fragment = NULL;
|
||||
}
|
||||
tf_free(connection);
|
||||
|
||||
if (http->is_shutting_down &&
|
||||
http->connections_count == 0)
|
||||
{
|
||||
tf_http_destroy(http);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -687,6 +695,18 @@ static void _http_free_listener_on_close(uv_handle_t* handle)
|
||||
|
||||
void tf_http_destroy(tf_http_t* http)
|
||||
{
|
||||
http->is_shutting_down = true;
|
||||
|
||||
for (int i = 0; i < http->connections_count; i++)
|
||||
{
|
||||
_http_connection_destroy(http->connections[i], "tf_http_destroy");
|
||||
}
|
||||
|
||||
if (http->connections_count == 0)
|
||||
{
|
||||
tf_free(http->connections);
|
||||
http->connections = NULL;
|
||||
|
||||
for (int i = 0; i < http->listeners_count; i++)
|
||||
{
|
||||
tf_http_listener_t* listener = http->listeners[i];
|
||||
@ -715,13 +735,6 @@ void tf_http_destroy(tf_http_t* http)
|
||||
tf_free(http->handlers);
|
||||
http->handlers_count = 0;
|
||||
|
||||
for (int i = 0; i < http->connections_count; i++)
|
||||
{
|
||||
_http_connection_destroy(http->connections[i], "tf_http_destroy");
|
||||
}
|
||||
tf_free(http->connections);
|
||||
http->connections_count = 0;
|
||||
|
||||
if (http->user_data_cleanup)
|
||||
{
|
||||
http->user_data_cleanup(http->user_data);
|
||||
@ -730,6 +743,7 @@ void tf_http_destroy(tf_http_t* http)
|
||||
|
||||
tf_free(http);
|
||||
}
|
||||
}
|
||||
|
||||
const char* tf_http_status_text(int status)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user