From ae545e7b2bb3691e82d9c75a28aacd4e1f206601 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 9 Nov 2022 23:25:22 +0000 Subject: [PATCH] Minor cleanup. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4028 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/ssb.js | 7 +++++-- src/ssb.c | 9 ++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/ssb.js b/core/ssb.js index 020b514e..71be774b 100644 --- a/core/ssb.js +++ b/core/ssb.js @@ -111,7 +111,7 @@ ssb.addEventListener('connections', function on_connections_changed(change, conn }); } else { if (connection.is_client) { - connection.send_json({'name': ['tunnel', 'isRoom'], 'args': [], 'type': 'source'}, function tunnel_is_room(request) { + connection.send_json({'name': ['tunnel', 'isRoom'], 'args': []}, function tunnel_is_room(request) { if (request.message) { connection.send_json({'name': ['room', 'attendants'], 'args': [], 'type': 'source'}, tunnel_attendants); } @@ -165,7 +165,7 @@ ssb.addEventListener('connections', function on_connections_changed(change, conn }); function blob_want_discovered(request, id) { - if (Object.keys(request.connection.active_blob_wants).length > k_blobs_concurrent_target) { + if (!request || !request.connection || Object.keys(request.connection.active_blob_wants).length > k_blobs_concurrent_target) { return; } var message = {}; @@ -181,6 +181,9 @@ function requestMoreBlobs(request) { row => blob_want_discovered(request, row.id)); } +ssb.addRpc(['manifest'], function(request) { +}); + ssb.addRpc(['blobs', 'createWants'], function(request) { g_wants_requests[request.connection.id] = request; ssb.addEventListener('blob_want_added', id => blob_want_discovered(request, id)); diff --git a/src/ssb.c b/src/ssb.c index 63ba3bda..a81083f8 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2027,11 +2027,11 @@ tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, c { for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next) { - if (memcmp(connection->serverpub, public_key, k_id_bin_len) == 0) + if (memcmp(connection->serverpub, public_key, k_id_bin_len) == 0 && connection->state != k_tf_ssb_state_invalid) { char id[k_id_base64_len]; tf_ssb_id_bin_to_str(id, sizeof(id), public_key); - printf("Not connecting to %s:%d, because we are already connected to %s.\n", host, ntohs(addr->sin_port), id); + printf("Not connecting to %s:%d, because we are already connected to %s (state = %d).\n", host, ntohs(addr->sin_port), id, connection->state); return NULL; } else if (memcmp(ssb->pub, public_key, k_id_bin_len) == 0) @@ -2749,11 +2749,6 @@ JSClassID tf_ssb_get_connection_class_id() JSValue tf_ssb_connection_get_object(tf_ssb_connection_t* connection) { - if (connection && !JS_IsUndefined(connection->object)) - { - JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(connection->object); - printf("%p _get_object count=%d\nn", JS_VALUE_GET_PTR(connection->object), p->ref_count); - } return connection ? connection->object : JS_UNDEFINED; }