From 20701d9cf1e06a7bc0c99ad2924b91dc7c0bd6ef Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 13 Nov 2024 18:44:14 -0500 Subject: [PATCH] ssb: Missed a few connection failures for context. --- src/ssb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ssb.c b/src/ssb.c index 0a190b88..2f552696 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -511,7 +511,9 @@ static void _tf_ssb_write(tf_ssb_connection_t* connection, void* data, size_t si if (result) { tf_ssb_connection_adjust_write_count(connection, -1); - _tf_ssb_connection_close(connection, "write failed"); + char buffer[256]; + snprintf(buffer, sizeof(buffer), "write failed : %s", uv_strerror(result)); + _tf_ssb_connection_close(connection, buffer); tf_free(write); } } @@ -2127,8 +2129,9 @@ static bool _tf_ssb_connection_read_start(tf_ssb_connection_t* connection) int result = uv_read_start((uv_stream_t*)&connection->tcp, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv); if (result && result != UV_EALREADY) { - tf_printf("uv_read_start => %s\n", uv_strerror(result)); - _tf_ssb_connection_close(connection, "uv_read_start failed"); + char reason[1024]; + snprintf(reason, sizeof(reason), "uv_read_start failed: %s", uv_strerror(result)); + _tf_ssb_connection_close(connection, reason); return false; } return true; @@ -2139,8 +2142,9 @@ static bool _tf_ssb_connection_read_stop(tf_ssb_connection_t* connection) int result = uv_read_stop((uv_stream_t*)&connection->tcp); if (result && result != UV_EALREADY) { - tf_printf("uv_read_stop => %s\n", uv_strerror(result)); - _tf_ssb_connection_close(connection, "uv_read_stop failed"); + char reason[1024]; + snprintf(reason, sizeof(reason), "uv_read_stop failed: %s", uv_strerror(result)); + _tf_ssb_connection_close(connection, reason); return false; } return true; @@ -2160,7 +2164,9 @@ static void _tf_ssb_connection_on_connect(uv_connect_t* connect, int status) } else { - _tf_ssb_connection_close(connection, "uv_tcp_connect failed"); + char reason[1024]; + snprintf(reason, sizeof(reason), "uv_tcp_connect failed: %s", uv_strerror(status)); + _tf_ssb_connection_close(connection, reason); } }