forked from cory/tildefriends
Trying to make connections more robust.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4020 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
16
src/ssb.c
16
src/ssb.c
@ -1398,6 +1398,14 @@ void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* rea
|
||||
{
|
||||
_tf_ssb_connection_remove_request(connection, connection->requests->request_number);
|
||||
}
|
||||
for (tf_ssb_broadcast_t* node = ssb->broadcasts; node; node = node->next)
|
||||
{
|
||||
if (node->tunnel_connection == connection)
|
||||
{
|
||||
node->tunnel_connection = NULL;
|
||||
node->mtime = 0;
|
||||
}
|
||||
}
|
||||
for (tf_ssb_connection_t** it = &connection->ssb->connections; *it; it = &(*it)->next)
|
||||
{
|
||||
for (int i = 0; i < (*it)->requests_count; i++)
|
||||
@ -2049,7 +2057,6 @@ tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, c
|
||||
uv_async_init(ssb->loop, &connection->async, _tf_ssb_connection_process_message_async);
|
||||
|
||||
connection->object = JS_NewObjectClass(ssb->context, _connection_class_id);
|
||||
printf("%s = %p\n", connection->name, JS_VALUE_GET_PTR(connection->object));
|
||||
JS_SetOpaque(connection->object, connection);
|
||||
JS_SetPropertyStr(context, connection->object, "send_json", JS_NewCFunction(context, _tf_ssb_connection_send_json, "send_json", 2));
|
||||
char public_key_str[k_id_base64_len] = { 0 };
|
||||
@ -2109,7 +2116,6 @@ tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_connection_t* connec
|
||||
uv_async_init(ssb->loop, &tunnel->async, _tf_ssb_connection_process_message_async);
|
||||
|
||||
tunnel->object = JS_NewObjectClass(ssb->context, _connection_class_id);
|
||||
printf("%s = %p\n", tunnel->name, JS_VALUE_GET_PTR(connection->object));
|
||||
JS_SetOpaque(tunnel->object, tunnel);
|
||||
JS_SetPropertyStr(context, tunnel->object, "send_json", JS_NewCFunction(context, _tf_ssb_connection_send_json, "send_json", 2));
|
||||
JS_SetPropertyStr(context, tunnel->object, "id", JS_NewString(context, target_id));
|
||||
@ -2186,6 +2192,11 @@ void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* ke
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_connection_close(tf_ssb_connection_t* connection)
|
||||
{
|
||||
_tf_ssb_connection_close(connection, "tf_ssb_connection_close");
|
||||
}
|
||||
|
||||
static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
|
||||
{
|
||||
tf_ssb_t* ssb = stream->data;
|
||||
@ -2205,7 +2216,6 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
|
||||
uv_async_init(ssb->loop, &connection->async, _tf_ssb_connection_process_message_async);
|
||||
|
||||
connection->object = JS_NewObjectClass(ssb->context, _connection_class_id);
|
||||
printf("%s = %p\n", connection->name, JS_VALUE_GET_PTR(connection->object));
|
||||
JS_SetPropertyStr(ssb->context, connection->object, "send_json", JS_NewCFunction(ssb->context, _tf_ssb_connection_send_json, "send_json", 2));
|
||||
JS_SetOpaque(connection->object, connection);
|
||||
|
||||
|
Reference in New Issue
Block a user