forked from cory/tildefriends
More bugs.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3785 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -1219,6 +1219,7 @@ void tf_ssb_connection_destroy(tf_ssb_connection_t* connection)
|
||||
}
|
||||
if (!JS_IsUndefined(connection->object))
|
||||
{
|
||||
JS_SetOpaque(connection->object, NULL);
|
||||
JS_FreeValue(ssb->context, connection->object);
|
||||
connection->object = JS_UNDEFINED;
|
||||
}
|
||||
@ -1884,6 +1885,7 @@ 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);
|
||||
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 };
|
||||
if (tf_ssb_id_bin_to_str(public_key_str, sizeof(public_key_str), public_key))
|
||||
@ -1891,7 +1893,6 @@ tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, c
|
||||
JS_SetPropertyStr(context, connection->object, "id", JS_NewString(context, public_key_str));
|
||||
JS_SetPropertyStr(context, connection->object, "is_client", JS_TRUE);
|
||||
}
|
||||
JS_SetOpaque(connection->object, connection);
|
||||
|
||||
memcpy(connection->serverpub, public_key, sizeof(connection->serverpub));
|
||||
|
||||
@ -1901,7 +1902,7 @@ tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, c
|
||||
if (result)
|
||||
{
|
||||
printf("uv_tcp_connect(%s): %s\n", host, uv_strerror(result));
|
||||
JS_FreeValue(ssb->context, connection->object);
|
||||
tf_ssb_connection_destroy(connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user