Save more context about closed connections, and include the timestamp.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4411 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-08-20 18:36:46 +00:00
parent befff5c1e5
commit 85acac3a30

View File

@ -73,8 +73,8 @@ typedef enum {
enum {
k_connections_changed_callbacks_max = 8,
k_tf_ssb_rpc_message_body_length_max = 1 * 1024 * 1024,
k_debug_close_message_count = 32,
k_debug_close_connection_count = 8,
k_debug_close_message_count = 256,
k_debug_close_connection_count = 32,
};
typedef struct _tf_ssb_broadcast_t tf_ssb_broadcast_t;
@ -86,6 +86,7 @@ typedef struct _tf_ssb_debug_message_t
bool outgoing;
int flags;
int32_t request_number;
time_t timestamp;
size_t size;
uint8_t data[];
} tf_ssb_debug_message_t;
@ -377,6 +378,7 @@ static void _tf_ssb_connection_add_debug_message(tf_ssb_connection_t* connection
.outgoing = outgoing,
.flags = flags,
.request_number = request_number,
.timestamp = time(NULL),
.size = size,
};
memcpy(message + 1, data, size);
@ -3533,6 +3535,7 @@ JSValue tf_ssb_get_disconnection_debug(tf_ssb_t* ssb, JSContext* context)
JS_SetPropertyStr(context, message, "direction", JS_NewString(context, ssb->debug_close[i].messages[j]->outgoing ? "out" : "in"));
JS_SetPropertyStr(context, message, "flags", JS_NewInt32(context, ssb->debug_close[i].messages[j]->flags));
JS_SetPropertyStr(context, message, "request_number", JS_NewInt32(context, ssb->debug_close[i].messages[j]->request_number));
JS_SetPropertyStr(context, message, "timestamp", JS_NewFloat64(context, ssb->debug_close[i].messages[j]->timestamp));
JS_SetPropertyStr(context, message, "payload", JS_NewStringLen(context, (const char*)ssb->debug_close[i].messages[j]->data, ssb->debug_close[i].messages[j]->size));
JS_SetPropertyUint32(context, messages, j, message);
}