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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -238,4 +238,9 @@ const char* tf_http_status_text(int status);
|
||||
*/
|
||||
bool tf_http_pattern_matches(const char* pattern, const char* path);
|
||||
|
||||
/**
|
||||
** Log debug information to diagnose shutdown problems.
|
||||
*/
|
||||
void tf_http_debug_destroy();
|
||||
|
||||
/** @} */
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "ssb.h"
|
||||
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.connections.h"
|
||||
@@ -2711,6 +2712,7 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
|
||||
tf_printf("--\n");
|
||||
uv_print_all_handles(ssb->loop, stdout);
|
||||
}
|
||||
tf_http_debug_destroy();
|
||||
uv_run(ssb->loop, UV_RUN_ONCE);
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "api.js.h"
|
||||
#include "database.js.h"
|
||||
#include "file.js.h"
|
||||
#include "http.h"
|
||||
#include "httpd.js.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
@@ -1875,6 +1876,7 @@ void tf_task_destroy(tf_task_t* task)
|
||||
tf_printf("--\n");
|
||||
uv_print_all_handles(&task->_loop, stdout);
|
||||
}
|
||||
tf_http_debug_destroy();
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
if (task->_trace)
|
||||
|
Reference in New Issue
Block a user