From 862d172ca868e7aa90eaa1e0f317ffc245c727ce Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 16 Mar 2025 19:30:35 -0400 Subject: [PATCH] ssb: Pub blobs in the idle queue, too. I'm confused why things aren't moving like I'd expect. This seems more fair. --- src/ssb.rpc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 454ef632..edab7f0e 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -671,6 +671,22 @@ static void _tf_ssb_rpc_connection_blobs_create_wants_after_work(tf_ssb_connecti tf_free(work); } +typedef struct _blob_get_t +{ + char id[k_blob_id_len]; + size_t size; +} blob_get_t; + +static void _tf_ssb_rpc_connection_blobs_get_idle(tf_ssb_connection_t* connection, bool skip, void* user_data) +{ + blob_get_t* get = user_data; + if (!skip) + { + _tf_ssb_rpc_connection_blobs_get(connection, get->id, get->size); + } + tf_free(get); +} + static void _tf_ssb_rpc_connection_blobs_createWants_callback( tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue args, const uint8_t* message, size_t size, void* user_data) { @@ -725,7 +741,10 @@ static void _tf_ssb_rpc_connection_blobs_createWants_callback( } else { - _tf_ssb_rpc_connection_blobs_get(connection, blob_id, size); + blob_get_t* get = tf_malloc(sizeof(blob_get_t)); + *get = (blob_get_t) { .size = size }; + snprintf(get->id, sizeof(get->id), "%s", blob_id); + tf_ssb_connection_schedule_idle(connection, blob_id, _tf_ssb_rpc_connection_blobs_get_idle, get); } JS_FreeCString(context, blob_id); JS_FreeValue(context, key);