ssb: Shutdown fixes.

This commit is contained in:
Cory McWilliams 2024-11-25 17:14:16 -05:00
parent a08bba438e
commit 71444b0427
3 changed files with 29 additions and 7 deletions

View File

@ -0,0 +1,12 @@
* Improve, test, and fix some first time flow issues.
* Show reasons for failing to connect.
* Actually use CommonMark JS in "safe" mode(!).
* Move app blob handling from JS to C.
* Fixed "publish" command-line interface and used it to add a script that posts development activity updates.
* Minor style improvements.
* Make it possible to see the little graphs on mobile.
* Updated dependencies:
* libbacktrace
* CodeMirror
* c-ares 1.34.3
* speedscope 1.21.0

View File

@ -220,6 +220,7 @@ typedef struct _tf_ssb_t
bool verbose;
bool store_debug_messages;
bool shutting_down;
bool shutting_down_deferred;
int messages_stored;
int blobs_stored;
@ -2009,7 +2010,7 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
connection->debug_messages[i] = NULL;
}
if (--connection->ssb->connection_ref_count == 0 && connection->ssb->shutting_down)
if (--connection->ssb->connection_ref_count == 0 && connection->ssb->shutting_down_deferred)
{
tf_ssb_destroy(connection->ssb);
}
@ -2516,12 +2517,6 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
tf_printf("tf_ssb_destroy\n");
ssb->shutting_down = true;
if (ssb->connections_tracker)
{
tf_ssb_connections_destroy(ssb->connections_tracker);
ssb->connections_tracker = NULL;
}
if (ssb->broadcast_listener.data && !uv_is_closing((uv_handle_t*)&ssb->broadcast_listener))
{
uv_close((uv_handle_t*)&ssb->broadcast_listener, _tf_ssb_on_handle_close);
@ -2637,10 +2632,20 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
tf_ssb_connection_close(connection);
connection = next;
}
uv_run(ssb->loop, UV_RUN_NOWAIT);
tf_printf("Closed.\n");
if (ssb->connections_tracker)
{
tf_ssb_connections_destroy(ssb->connections_tracker);
ssb->connections_tracker = NULL;
}
uv_run(ssb->loop, UV_RUN_NOWAIT);
if (ssb->loop == &ssb->own_loop)
{
tf_printf("uv_loop_close\n");
int r = uv_loop_close(ssb->loop);
if (r != 0)
{
@ -2695,6 +2700,7 @@ void tf_ssb_destroy(tf_ssb_t* ssb)
ssb->room_name = NULL;
}
ssb->shutting_down_deferred = true;
if (ssb->connection_ref_count == 0)
{
uv_mutex_destroy(&ssb->db_readers_lock);

View File

@ -112,6 +112,10 @@ static void _tf_ssb_connections_get_next_after_work(tf_ssb_t* ssb, int status, v
static void _tf_ssb_connections_timer(uv_timer_t* timer)
{
tf_ssb_connections_t* connections = timer->data;
if (tf_ssb_is_shutting_down(connections->ssb))
{
return;
}
tf_ssb_connection_t* active[4];
int count = tf_ssb_get_connections(connections->ssb, active, tf_countof(active));
if (count < tf_countof(active))