forked from cory/tildefriends
Fix an http use after free during shutdown.
This commit is contained in:
parent
610e756c07
commit
5385264f94
20
src/http.c
20
src/http.c
@ -381,11 +381,19 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
|
||||
};
|
||||
connection->request = request;
|
||||
|
||||
tf_http_request_ref(request);
|
||||
tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "http");
|
||||
connection->callback(request);
|
||||
tf_trace_end(connection->http->trace);
|
||||
tf_http_request_unref(request);
|
||||
if (!connection->http->is_shutting_down)
|
||||
{
|
||||
tf_http_request_ref(request);
|
||||
tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "http");
|
||||
connection->callback(request);
|
||||
tf_trace_end(connection->http->trace);
|
||||
tf_http_request_unref(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* k_payload = tf_http_status_text(503);
|
||||
tf_http_respond(request, 503, NULL, 0, k_payload, strlen(k_payload));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -784,6 +792,8 @@ const char* tf_http_status_text(int status)
|
||||
return "File not found";
|
||||
case 500:
|
||||
return "Internal server error";
|
||||
case 503:
|
||||
return "Service Unavailable";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user