forked from cory/tildefriends
ssb: Populate more connection errors with context.
This commit is contained in:
parent
68ff77e172
commit
fa94442eb2
19
src/ssb.c
19
src/ssb.c
@ -2779,9 +2779,10 @@ static tf_ssb_connection_t* _tf_ssb_connection_create(
|
|||||||
int result = uv_tcp_connect(&connection->connect, &connection->tcp, (const struct sockaddr*)addr, _tf_ssb_connection_on_connect);
|
int result = uv_tcp_connect(&connection->connect, &connection->tcp, (const struct sockaddr*)addr, _tf_ssb_connection_on_connect);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
tf_printf("uv_tcp_connect(%s): %s\n", host, uv_strerror(result));
|
char reason[1024];
|
||||||
|
snprintf(reason, sizeof(reason), "uv_tcp_connect(%s) => %s", host, uv_strerror(result));
|
||||||
connection->connect.data = NULL;
|
connection->connect.data = NULL;
|
||||||
_tf_ssb_connection_destroy(connection, "connect failed");
|
_tf_ssb_connection_destroy(connection, reason);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2966,15 +2967,21 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
|
|||||||
connection->object = JS_NewObjectClass(ssb->context, _connection_class_id);
|
connection->object = JS_NewObjectClass(ssb->context, _connection_class_id);
|
||||||
JS_SetOpaque(connection->object, connection);
|
JS_SetOpaque(connection->object, connection);
|
||||||
|
|
||||||
if (uv_tcp_init(ssb->loop, &connection->tcp) != 0)
|
int result = uv_tcp_init(ssb->loop, &connection->tcp);
|
||||||
|
if (result != 0)
|
||||||
{
|
{
|
||||||
_tf_ssb_connection_destroy(connection, "init failed");
|
char reason[1024];
|
||||||
|
snprintf(reason, sizeof(reason), "uv_tcp_init() => %s", uv_strerror(result));
|
||||||
|
_tf_ssb_connection_destroy(connection, reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uv_accept(stream, (uv_stream_t*)&connection->tcp) != 0)
|
result = uv_accept(stream, (uv_stream_t*)&connection->tcp);
|
||||||
|
if (result != 0)
|
||||||
{
|
{
|
||||||
_tf_ssb_connection_destroy(connection, "accept failed");
|
char reason[1024];
|
||||||
|
snprintf(reason, sizeof(reason), "uv_accept() => %s", uv_strerror(result));
|
||||||
|
_tf_ssb_connection_destroy(connection, reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user