Ever closer to the elusive clean http shutdown.
This commit is contained in:
parent
15c9f8f458
commit
610e756c07
14
src/http.c
14
src/http.c
@ -161,10 +161,11 @@ static void _http_request_destroy(tf_http_request_t* request)
|
||||
tf_http_close_callback* on_close = request->on_close;
|
||||
if (on_close)
|
||||
{
|
||||
tf_trace_t* trace = request->http->trace;
|
||||
request->on_close = NULL;
|
||||
tf_trace_begin(request->http->trace, request->connection && request->connection->trace_name ? request->connection->trace_name : "websocket");
|
||||
tf_trace_begin(trace, request->connection && request->connection->trace_name ? request->connection->trace_name : "websocket");
|
||||
on_close(request);
|
||||
tf_trace_end(request->http->trace);
|
||||
tf_trace_end(trace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,12 +175,9 @@ static void _http_connection_destroy(tf_http_connection_t* connection, const cha
|
||||
|
||||
if (connection->request)
|
||||
{
|
||||
_http_request_destroy(connection->request);
|
||||
if (connection->request && connection->request->ref_count == 0)
|
||||
{
|
||||
tf_free(connection->request);
|
||||
}
|
||||
tf_http_request_t* request = connection->request;
|
||||
connection->request = NULL;
|
||||
_http_request_destroy(request);
|
||||
}
|
||||
|
||||
if (connection->tcp.data && !uv_is_closing((uv_handle_t*)&connection->tcp))
|
||||
@ -965,11 +963,11 @@ void tf_http_request_unref(tf_http_request_t* request)
|
||||
tf_http_connection_t* connection = request->connection;
|
||||
if (--request->ref_count == 0)
|
||||
{
|
||||
_http_request_destroy(request);
|
||||
if (connection)
|
||||
{
|
||||
connection->request = NULL;
|
||||
}
|
||||
_http_request_destroy(request);
|
||||
tf_free(request);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user