forked from cory/tildefriends
Disable storing messages for disconnection debug by default, and add another environment variable for logging SSB RPC messages.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4751 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
2353b43514
commit
b40457d774
18
src/ssb.c
18
src/ssb.c
@ -203,6 +203,7 @@ typedef struct _tf_ssb_t
|
||||
uint8_t priv[crypto_sign_SECRETKEYBYTES];
|
||||
|
||||
bool verbose;
|
||||
bool store_debug_messages;
|
||||
|
||||
int messages_stored;
|
||||
int blobs_stored;
|
||||
@ -349,6 +350,11 @@ static void _tf_ssb_start_update_settings(tf_ssb_t* ssb, int delay_ms);
|
||||
|
||||
static void _tf_ssb_add_debug_close(tf_ssb_t* ssb, tf_ssb_connection_t* connection, const char* reason)
|
||||
{
|
||||
if (!ssb->store_debug_messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < k_debug_close_message_count; i++)
|
||||
{
|
||||
tf_free(ssb->debug_close[k_debug_close_connection_count - 1].messages[i]);
|
||||
@ -374,6 +380,11 @@ static void _tf_ssb_add_debug_close(tf_ssb_t* ssb, tf_ssb_connection_t* connecti
|
||||
|
||||
static void _tf_ssb_connection_add_debug_message(tf_ssb_connection_t* connection, bool outgoing, int flags, int32_t request_number, const uint8_t* data, size_t size)
|
||||
{
|
||||
if (!connection->ssb->store_debug_messages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (connection->debug_messages[k_debug_close_message_count - 1])
|
||||
{
|
||||
tf_free(connection->debug_messages[k_debug_close_message_count - 1]);
|
||||
@ -2134,6 +2145,13 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
||||
{
|
||||
tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t));
|
||||
memset(ssb, 0, sizeof(*ssb));
|
||||
|
||||
char buffer[8] = { 0 };
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
ssb->store_debug_messages = uv_os_getenv("TF_DEBUG_CLOSE", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
buffer_size = sizeof(buffer);
|
||||
ssb->verbose = uv_os_getenv("TF_SSB_VERBOSE", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
|
||||
if (context)
|
||||
{
|
||||
ssb->context = context;
|
||||
|
Loading…
Reference in New Issue
Block a user