From a4acee49392386779fee0ddcbaf60c81267f42e5 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 6 Jul 2023 00:35:39 +0000 Subject: [PATCH] Fix a stall where we would process one scheduled task and then leave the rest until we wake up again from network traffic. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4338 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ssb.c b/src/ssb.c index 73fd6ea0..a6da193c 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -1740,7 +1740,8 @@ void tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connection) { - if (connection->scheduled_count) + const int k_scheduled_batch_count = 8; + for (int i = 0; i < k_scheduled_batch_count && connection->scheduled_count; i++) { tf_ssb_connection_scheduled_t scheduled = connection->scheduled[0]; memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1)); @@ -1749,6 +1750,10 @@ static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connectio scheduled.callback(connection, scheduled.user_data); tf_trace_end(connection->ssb->trace); } + if (connection->scheduled_count) + { + uv_async_send(&connection->async); + } } static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* reason)