Fix an RPC stall? How did this ever work? How is it supposed to work?
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4098 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
7cba1b21ad
commit
5342ddb2bd
11
src/ssb.c
11
src/ssb.c
@ -218,7 +218,7 @@ typedef struct _tf_ssb_connection_t
|
|||||||
uint8_t s_to_c_box_key[crypto_hash_sha256_BYTES];
|
uint8_t s_to_c_box_key[crypto_hash_sha256_BYTES];
|
||||||
uint8_t c_to_s_box_key[crypto_hash_sha256_BYTES];
|
uint8_t c_to_s_box_key[crypto_hash_sha256_BYTES];
|
||||||
|
|
||||||
uint8_t recv_buffer[8192];
|
uint8_t recv_buffer[32 * 1024];
|
||||||
size_t recv_size;
|
size_t recv_size;
|
||||||
|
|
||||||
uint8_t nonce[crypto_secretbox_NONCEBYTES];
|
uint8_t nonce[crypto_secretbox_NONCEBYTES];
|
||||||
@ -531,7 +531,7 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
|||||||
memcpy(combined + 1 + 2 * sizeof(uint32_t), message, size);
|
memcpy(combined + 1 + 2 * sizeof(uint32_t), message, size);
|
||||||
if (connection->ssb->verbose)
|
if (connection->ssb->verbose)
|
||||||
{
|
{
|
||||||
printf(MAGENTA "%s RPC SEND" RESET " flags=%x RN=%d: %.*s\n", connection->name, flags, request_number, (flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary? 0 : (int)size, message);
|
printf(MAGENTA "%s RPC SEND" RESET " flags=%x RN=%d: [%zd B] %.*s\n", connection->name, flags, request_number, size, (flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary ? 0 : (int)size, message);
|
||||||
}
|
}
|
||||||
_tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size);
|
_tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size);
|
||||||
tf_free(combined);
|
tf_free(combined);
|
||||||
@ -1088,6 +1088,12 @@ static void _tf_ssb_connection_verify_client_identity(tf_ssb_connection_t* conne
|
|||||||
|
|
||||||
static bool _tf_ssb_connection_recv_pop(tf_ssb_connection_t* connection, uint8_t* buffer, size_t size)
|
static bool _tf_ssb_connection_recv_pop(tf_ssb_connection_t* connection, uint8_t* buffer, size_t size)
|
||||||
{
|
{
|
||||||
|
if (size >= sizeof(connection->recv_buffer))
|
||||||
|
{
|
||||||
|
char message[256];
|
||||||
|
snprintf(message, sizeof(message), "Trying to pop a message (%zd) larger than the connection's receive buffer (%zd).", size, sizeof(connection->recv_buffer));
|
||||||
|
_tf_ssb_connection_close(connection, message);
|
||||||
|
}
|
||||||
if (connection->recv_size < size)
|
if (connection->recv_size < size)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -1176,6 +1182,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
{
|
{
|
||||||
if (_tf_ssb_name_equals(context, val, it->name))
|
if (_tf_ssb_name_equals(context, val, it->name))
|
||||||
{
|
{
|
||||||
|
printf("called it\n");
|
||||||
it->callback(connection, flags, request_number, val, NULL, 0, it->user_data);
|
it->callback(connection, flags, request_number, val, NULL, 0, it->user_data);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -45,7 +45,7 @@ static void _tf_ssb_rpc_blobs_get(tf_ssb_connection_t* connection, uint8_t flags
|
|||||||
const char* id = JS_ToCString(context, arg);
|
const char* id = JS_ToCString(context, arg);
|
||||||
uint8_t* blob = NULL;
|
uint8_t* blob = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const int k_send_max = 8192;
|
const int k_send_max = 4096;
|
||||||
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
|
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
|
||||||
{
|
{
|
||||||
for (size_t offset = 0; offset < size; offset += k_send_max)
|
for (size_t offset = 0; offset < size; offset += k_send_max)
|
||||||
|
@ -625,4 +625,5 @@ void tf_ssb_test_bench(const tf_test_options_t* options)
|
|||||||
uv_loop_close(&loop);
|
uv_loop_close(&loop);
|
||||||
|
|
||||||
sqlite3_close(db0);
|
sqlite3_close(db0);
|
||||||
|
sqlite3_close(db1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user