ssb: Don't schedule duplicate history stream requests for the same account. Changes how we schedule idle work. Let's see if this is better.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 22m35s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 22m35s
This commit is contained in:
@ -855,6 +855,16 @@ static void _tf_ssb_connection_send_history_stream_work(tf_ssb_connection_t* con
|
||||
request->out_finished = request->out_max_sequence_seen != request->sequence + k_max - 1;
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_send_history_stream_destroy(tf_ssb_connection_send_history_stream_t* request)
|
||||
{
|
||||
for (int i = 0; i < request->out_messages_count; i++)
|
||||
{
|
||||
tf_free(request->out_messages[i]);
|
||||
}
|
||||
tf_free(request->out_messages);
|
||||
tf_free(request);
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_send_history_stream_after_work(tf_ssb_connection_t* connection, int result, void* user_data)
|
||||
{
|
||||
tf_ssb_connection_send_history_stream_t* request = user_data;
|
||||
@ -879,24 +889,19 @@ static void _tf_ssb_connection_send_history_stream_after_work(tf_ssb_connection_
|
||||
tf_ssb_connection_rpc_send(connection, k_ssb_rpc_flag_json, request->request_number, NULL, (const uint8_t*)"false", strlen("false"), NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < request->out_messages_count; i++)
|
||||
{
|
||||
tf_free(request->out_messages[i]);
|
||||
}
|
||||
tf_free(request->out_messages);
|
||||
tf_free(request);
|
||||
_tf_ssb_connection_send_history_stream_destroy(request);
|
||||
}
|
||||
|
||||
static void _tf_ssb_connection_send_history_stream_callback(tf_ssb_connection_t* connection, void* user_data)
|
||||
static void _tf_ssb_connection_send_history_stream_callback(tf_ssb_connection_t* connection, bool skip, void* user_data)
|
||||
{
|
||||
tf_ssb_connection_adjust_write_count(connection, 1);
|
||||
if (tf_ssb_connection_is_connected(connection) && !tf_ssb_is_shutting_down(tf_ssb_connection_get_ssb(connection)))
|
||||
if (!skip && tf_ssb_connection_is_connected(connection) && !tf_ssb_is_shutting_down(tf_ssb_connection_get_ssb(connection)))
|
||||
{
|
||||
tf_ssb_connection_run_work(connection, _tf_ssb_connection_send_history_stream_work, _tf_ssb_connection_send_history_stream_after_work, user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_ssb_connection_send_history_stream_after_work(connection, -1, user_data);
|
||||
_tf_ssb_connection_send_history_stream_destroy(user_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,7 +919,7 @@ static void _tf_ssb_connection_send_history_stream(
|
||||
.end_request = end_request,
|
||||
};
|
||||
snprintf(async->author, sizeof(async->author), "%s", author);
|
||||
tf_ssb_connection_schedule_idle(connection, _tf_ssb_connection_send_history_stream_callback, async);
|
||||
tf_ssb_connection_schedule_idle(connection, author, _tf_ssb_connection_send_history_stream_callback, async);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1166,11 +1171,14 @@ typedef struct _resend_clock_t
|
||||
int32_t request_number;
|
||||
} resend_clock_t;
|
||||
|
||||
static void _tf_ssb_rpc_ebt_replicate_resend_clock(tf_ssb_connection_t* connection, void* user_data)
|
||||
static void _tf_ssb_rpc_ebt_replicate_resend_clock(tf_ssb_connection_t* connection, bool skip, void* user_data)
|
||||
{
|
||||
resend_clock_t* resend = user_data;
|
||||
_tf_ssb_rpc_ebt_replicate_send_clock(resend->connection, resend->request_number, JS_UNDEFINED);
|
||||
tf_ssb_connection_set_sent_clock(resend->connection, true);
|
||||
if (!skip)
|
||||
{
|
||||
_tf_ssb_rpc_ebt_replicate_send_clock(resend->connection, resend->request_number, JS_UNDEFINED);
|
||||
tf_ssb_connection_set_sent_clock(resend->connection, true);
|
||||
}
|
||||
tf_free(user_data);
|
||||
}
|
||||
|
||||
@ -1208,7 +1216,7 @@ static void _tf_ssb_rpc_ebt_replicate(tf_ssb_connection_t* connection, uint8_t f
|
||||
.connection = connection,
|
||||
.request_number = request_number,
|
||||
};
|
||||
tf_ssb_connection_schedule_idle(connection, _tf_ssb_rpc_ebt_replicate_resend_clock, resend);
|
||||
tf_ssb_connection_schedule_idle(connection, "ebt.clock", _tf_ssb_rpc_ebt_replicate_resend_clock, resend);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user