ssb: Try harder to avoid doing things with new connections during shutdown.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 26m2s

This commit is contained in:
Cory McWilliams 2025-01-16 12:47:50 -05:00
parent 5ce4f55228
commit 3e3d58a4a9
2 changed files with 12 additions and 1 deletions

View File

@ -629,6 +629,12 @@ static void _http_on_connection(uv_stream_t* stream, int status)
{ {
tf_http_listener_t* listener = stream->data; tf_http_listener_t* listener = stream->data;
tf_http_t* http = listener->http; tf_http_t* http = listener->http;
if (http->is_shutting_down)
{
tf_printf("Ignoring HTTP connection during shutdown.\n");
return;
}
tf_http_connection_t* connection = tf_malloc(sizeof(tf_http_connection_t)); tf_http_connection_t* connection = tf_malloc(sizeof(tf_http_connection_t));
*connection = (tf_http_connection_t) { .http = http, .tcp = { .data = connection }, .is_receiving_headers = true }; *connection = (tf_http_connection_t) { .http = http, .tcp = { .data = connection }, .is_receiving_headers = true };
if (listener->tls) if (listener->tls)

View File

@ -2926,7 +2926,7 @@ static void _tf_ssb_connection_tunnel_callback(
tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* portal_id, int32_t request_number, const char* target_id, int connect_flags) tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* portal_id, int32_t request_number, const char* target_id, int connect_flags)
{ {
tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id); tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id);
if (!connection) if (!connection || ssb->shutting_down)
{ {
return NULL; return NULL;
} }
@ -3052,6 +3052,11 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
return; return;
} }
if (ssb->shutting_down)
{
tf_printf("Ignoring SHS connection during shutdown.\n");
}
tf_ssb_connection_t* connection = _tf_ssb_connection_create_internal(ssb, "srv", s_connection_index++); tf_ssb_connection_t* connection = _tf_ssb_connection_create_internal(ssb, "srv", s_connection_index++);
connection->tcp.data = connection; connection->tcp.data = connection;