ssb: Indicate which muxrpc sends failed, and use that to fix some replication nonsense and log noise.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 15m22s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 15m22s
This commit is contained in:
27
src/ssb.c
27
src/ssb.c
@ -835,7 +835,7 @@ void tf_ssb_connection_remove_request(tf_ssb_connection_t* connection, int32_t r
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, const uint8_t* message, size_t size,
|
||||
bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, const uint8_t* message, size_t size,
|
||||
tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data)
|
||||
{
|
||||
if (!connection)
|
||||
@ -844,7 +844,7 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
||||
{
|
||||
cleanup(NULL, user_data);
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (flags & k_ssb_rpc_flag_new_request)
|
||||
{
|
||||
@ -856,13 +856,13 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
||||
{
|
||||
if (flags & k_ssb_rpc_flag_binary)
|
||||
{
|
||||
tf_printf("Dropping message with no active request (%d): (%zd bytes).\n", request_number, size);
|
||||
tf_printf(MAGENTA "%s RPC DROP" RESET " message with no active request (%d): (%zd bytes).\n", connection->name, request_number, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("Dropping message with no active request (%d): %.*s\n", request_number, (int)size, message);
|
||||
tf_printf(MAGENTA "%s RPC DROP" RESET " message with no active request (%d): %.*s\n", connection->name, request_number, (int)size, message);
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t* combined = tf_malloc(9 + size);
|
||||
@ -890,22 +890,24 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
||||
{
|
||||
tf_ssb_connection_add_request(connection, request_number, new_request_name, callback, cleanup, user_data, NULL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, JSValue message,
|
||||
bool tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, JSValue message,
|
||||
tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data)
|
||||
{
|
||||
JSContext* context = connection->ssb->context;
|
||||
JSValue json = JS_JSONStringify(context, message, JS_NULL, JS_NULL);
|
||||
size_t size = 0;
|
||||
const char* json_string = JS_ToCStringLen(context, &size, json);
|
||||
tf_ssb_connection_rpc_send(
|
||||
bool result = tf_ssb_connection_rpc_send(
|
||||
connection, k_ssb_rpc_flag_json | (flags & ~k_ssb_rpc_mask_type), request_number, new_request_name, (const uint8_t*)json_string, size, callback, cleanup, user_data);
|
||||
JS_FreeCString(context, json_string);
|
||||
JS_FreeValue(context, json);
|
||||
return result;
|
||||
}
|
||||
|
||||
void tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* error)
|
||||
bool tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* error)
|
||||
{
|
||||
JSContext* context = connection->ssb->context;
|
||||
JSValue message = JS_NewObject(context);
|
||||
@ -913,17 +915,18 @@ void tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t f
|
||||
JS_SetPropertyStr(context, message, "name", JS_NewString(context, "Error"));
|
||||
JS_SetPropertyStr(context, message, "stack", JS_NewString(context, stack ? stack : "stack unavailable"));
|
||||
JS_SetPropertyStr(context, message, "message", JS_NewString(context, error));
|
||||
tf_ssb_connection_rpc_send_json(
|
||||
bool result = tf_ssb_connection_rpc_send_json(
|
||||
connection, ((flags & k_ssb_rpc_flag_stream) ? (k_ssb_rpc_flag_stream) : 0) | k_ssb_rpc_flag_end_error, request_number, NULL, message, NULL, NULL, NULL);
|
||||
JS_FreeValue(context, message);
|
||||
tf_free((void*)stack);
|
||||
return result;
|
||||
}
|
||||
|
||||
void tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* name)
|
||||
bool tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* name)
|
||||
{
|
||||
char buffer[1024];
|
||||
char buffer[1024] = "";
|
||||
snprintf(buffer, sizeof(buffer), "method '%s' is not in list of allowed methods", name);
|
||||
tf_ssb_connection_rpc_send_error(connection, flags, request_number, buffer);
|
||||
return tf_ssb_connection_rpc_send_error(connection, flags, request_number, buffer);
|
||||
}
|
||||
|
||||
static int _utf8_len(uint8_t ch)
|
||||
|
Reference in New Issue
Block a user