ssb: Instrument some more callbacks for hitches.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled

This commit is contained in:
Cory McWilliams 2024-12-24 16:33:08 -05:00
parent 707b4990a6
commit fb0e4060cd

View File

@ -375,6 +375,8 @@ static int s_connection_index;
static int s_tunnel_index; static int s_tunnel_index;
static void _tf_ssb_add_broadcast(tf_ssb_t* ssb, const tf_ssb_broadcast_t* broadcast, int expires_seconds); static void _tf_ssb_add_broadcast(tf_ssb_t* ssb, const tf_ssb_broadcast_t* broadcast, int expires_seconds);
static uint64_t _tf_ssb_callback_pre(tf_ssb_t* ssb);
static void _tf_ssb_callback_post(tf_ssb_t* ssb, void* callback, uint64_t pre);
static void _tf_ssb_connection_client_send_hello(tf_ssb_connection_t* connection); static void _tf_ssb_connection_client_send_hello(tf_ssb_connection_t* connection);
static void _tf_ssb_connection_close(tf_ssb_connection_t* connection, const char* reason); static void _tf_ssb_connection_close(tf_ssb_connection_t* connection, const char* reason);
static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* reason); static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* reason);
@ -679,7 +681,9 @@ static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connectio
memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1)); memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1));
connection->scheduled_count--; connection->scheduled_count--;
tf_trace_begin(connection->ssb->trace, "scheduled callback"); tf_trace_begin(connection->ssb->trace, "scheduled callback");
PRE_CALLBACK(connection->ssb, scheduled.callback);
scheduled.callback(connection, scheduled.user_data); scheduled.callback(connection, scheduled.user_data);
POST_CALLBACK(connection->ssb, scheduled.callback);
tf_trace_end(connection->ssb->trace); tf_trace_end(connection->ssb->trace);
} }
} }
@ -1360,7 +1364,9 @@ static void _tf_ssb_connection_verify_identity(tf_ssb_connection_t* connection,
connection->state = k_tf_ssb_state_verified; connection->state = k_tf_ssb_state_verified;
if (connection->connect_callback) if (connection->connect_callback)
{ {
PRE_CALLBACK(connection->ssb, connection->connect_callback);
connection->connect_callback(connection, NULL, connection->connect_callback_user_data); connection->connect_callback(connection, NULL, connection->connect_callback_user_data);
POST_CALLBACK(connection->ssb, connection->connect_callback);
connection->connect_callback = NULL; connection->connect_callback = NULL;
connection->connect_callback_user_data = NULL; connection->connect_callback_user_data = NULL;
} }
@ -1923,7 +1929,9 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
connection->closing = true; connection->closing = true;
if (connection->connect_callback) if (connection->connect_callback)
{ {
PRE_CALLBACK(connection->ssb, connection->connect_callback);
connection->connect_callback(NULL, reason, connection->connect_callback_user_data); connection->connect_callback(NULL, reason, connection->connect_callback_user_data);
POST_CALLBACK(connection->ssb, connection->connect_callback);
connection->connect_callback = NULL; connection->connect_callback = NULL;
connection->connect_callback_user_data = NULL; connection->connect_callback_user_data = NULL;
} }
@ -3306,7 +3314,9 @@ static void _tf_ssb_notify_broadcasts_changed(tf_ssb_t* ssb)
if (node->callback) if (node->callback)
{ {
tf_trace_begin(ssb->trace, "broadcasts changed"); tf_trace_begin(ssb->trace, "broadcasts changed");
PRE_CALLBACK(ssb, node->callback);
node->callback(ssb, node->user_data); node->callback(ssb, node->user_data);
POST_CALLBACK(ssb, node->callback);
tf_trace_end(ssb->trace); tf_trace_end(ssb->trace);
} }
} }
@ -3410,7 +3420,9 @@ void tf_ssb_visit_broadcasts(tf_ssb_t* ssb,
if (node->mtime - now < 60) if (node->mtime - now < 60)
{ {
tf_trace_begin(ssb->trace, "broadcast"); tf_trace_begin(ssb->trace, "broadcast");
PRE_CALLBACK(ssb, callback);
callback(node->host, &node->addr, node->origin, node->tunnel_connection, node->pub, user_data); callback(node->host, &node->addr, node->origin, node->tunnel_connection, node->pub, user_data);
POST_CALLBACK(ssb, callback);
tf_trace_end(ssb->trace); tf_trace_end(ssb->trace);
} }
} }
@ -3718,7 +3730,9 @@ void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* id, JSValue message_
{ {
next = node->next; next = node->next;
tf_trace_begin(ssb->trace, "message added callback"); tf_trace_begin(ssb->trace, "message added callback");
PRE_CALLBACK(ssb, node->callback);
node->callback(ssb, id, node->user_data); node->callback(ssb, id, node->user_data);
POST_CALLBACK(ssb, node->callback);
tf_trace_end(ssb->trace); tf_trace_end(ssb->trace);
} }
@ -3794,7 +3808,9 @@ void tf_ssb_notify_blob_want_added(tf_ssb_t* ssb, const char* id)
{ {
next = node->next; next = node->next;
tf_trace_begin(ssb->trace, "blob want added callback"); tf_trace_begin(ssb->trace, "blob want added callback");
PRE_CALLBACK(ssb, node->callback);
node->callback(ssb, id, node->user_data); node->callback(ssb, id, node->user_data);
POST_CALLBACK(ssb, node->callback);
tf_trace_end(ssb->trace); tf_trace_end(ssb->trace);
} }
} }
@ -4071,7 +4087,9 @@ static void _tf_ssb_connection_after_work_callback(uv_work_t* work, int status)
if (data->after_work_callback) if (data->after_work_callback)
{ {
tf_trace_begin(data->connection->ssb->trace, data->after_name); tf_trace_begin(data->connection->ssb->trace, data->after_name);
PRE_CALLBACK(data->connection->ssb, data->after_work_callback);
data->after_work_callback(data->connection, status, data->user_data); data->after_work_callback(data->connection, status, data->user_data);
POST_CALLBACK(data->connection->ssb, data->after_work_callback);
tf_trace_end(data->connection->ssb->trace); tf_trace_end(data->connection->ssb->trace);
} }
data->connection->ref_count--; data->connection->ref_count--;
@ -4138,7 +4156,9 @@ static void _tf_ssb_after_work_callback(uv_work_t* work, int status)
if (data->after_work_callback) if (data->after_work_callback)
{ {
tf_trace_begin(data->ssb->trace, data->after_name); tf_trace_begin(data->ssb->trace, data->after_name);
PRE_CALLBACK(data->ssb, data->after_work_callback);
data->after_work_callback(data->ssb, status, data->user_data); data->after_work_callback(data->ssb, status, data->user_data);
POST_CALLBACK(data->ssb, data->after_work_callback);
tf_trace_end(data->ssb->trace); tf_trace_end(data->ssb->trace);
} }
tf_ssb_unref(data->ssb); tf_ssb_unref(data->ssb);
@ -4277,7 +4297,9 @@ void tf_ssb_set_verbose(tf_ssb_t* ssb, bool verbose)
static void _tf_ssb_scheduled_timer(uv_timer_t* handle) static void _tf_ssb_scheduled_timer(uv_timer_t* handle)
{ {
tf_ssb_timer_t* timer = handle->data; tf_ssb_timer_t* timer = handle->data;
PRE_CALLBACK(timer->ssb, timer->callback);
timer->callback(timer->ssb, timer->user_data); timer->callback(timer->ssb, timer->user_data);
POST_CALLBACK(timer->ssb, timer->callback);
uv_close((uv_handle_t*)handle, _tf_ssb_on_timer_close); uv_close((uv_handle_t*)handle, _tf_ssb_on_timer_close);
} }