http: Add some logging to try to diagnose an intermittent shutdown issue.
This commit is contained in:
36
src/http.c
36
src/http.c
@@ -20,6 +20,9 @@
|
||||
|
||||
static const int k_timeout_ms = 60000;
|
||||
|
||||
static tf_http_t** s_http_instances;
|
||||
int s_http_instance_count;
|
||||
|
||||
typedef struct _tf_http_connection_t
|
||||
{
|
||||
tf_http_t* http;
|
||||
@@ -115,6 +118,8 @@ tf_http_t* tf_http_create(uv_loop_t* loop)
|
||||
*http = (tf_http_t) {
|
||||
.loop = loop,
|
||||
};
|
||||
s_http_instances = tf_resize_vec(s_http_instances, sizeof(tf_http_t*) * (s_http_instance_count + 1));
|
||||
s_http_instances[s_http_instance_count++] = http;
|
||||
return http;
|
||||
}
|
||||
|
||||
@@ -872,6 +877,21 @@ void tf_http_destroy(tf_http_t* http)
|
||||
http->handlers_count = 0;
|
||||
|
||||
tf_free(http);
|
||||
|
||||
for (int i = 0; i < s_http_instance_count; i++)
|
||||
{
|
||||
if (s_http_instances[i] == http)
|
||||
{
|
||||
s_http_instances[i] = s_http_instances[--s_http_instance_count];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s_http_instance_count == 0)
|
||||
{
|
||||
tf_free(s_http_instances);
|
||||
s_http_instances = NULL;
|
||||
}
|
||||
tf_printf("http %p destroyed\n", http);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1215,3 +1235,19 @@ const char* tf_http_get_cookie(const char* cookie_header, const char* name)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void tf_http_debug_destroy()
|
||||
{
|
||||
for (int i = 0; i < s_http_instance_count; i++)
|
||||
{
|
||||
tf_http_t* http = s_http_instances[i];
|
||||
tf_printf("http %p[%d]\n", http, i);
|
||||
tf_printf(" connections = %d\n", http->connections_count);
|
||||
for (int j = 0; j < http->connections_count; j++)
|
||||
{
|
||||
tf_http_connection_t* connection = http->connections[j];
|
||||
tf_printf(" connection %p[%d] %s tcp=%p timeout=%p shutdown=%p rc=%d\n", connection, j, connection->trace_name, connection->tcp.data, connection->timeout.data,
|
||||
connection->shutdown.data, connection->ref_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user