Compare commits

..

No commits in common. "b222dc0ca83954bd1e592b49a04da4eeaf31545f" and "b95eed46bb1314efc8a1335db76ee3a5020c0ba2" have entirely different histories.

2 changed files with 14 additions and 25 deletions

View File

@ -103,6 +103,9 @@ BUILD_TYPES += \
androidrelease-x86_64
all: out/TildeFriends-arm-debug.apk out/TildeFriends-arm-release.apk out/TildeFriends-x86-debug.apk out/TildeFriends-x86-release.apk out/TildeFriends-release.fdroid.apk
endif
ifeq ($(UNAME_S),Linux)
all: appimage
endif
WINDOWS_TARGETS := \
out/windebug/tildefriends.exe \
@ -228,9 +231,6 @@ $(IOSSIM_TARGETS): CFLAGS += -Ideps/openssl/ios/iossimulator-xcrun/usr/local/inc
$(IOSSIM_TARGETS): LDFLAGS += -Ldeps/openssl/ios/iossimulator-xcrun/usr/local/lib
ifeq ($(UNAME_M),x86_64)
ifeq ($(UNAME_S),Linux)
all: appimage
endif
ifneq ($(UNAME_S),Haiku)
out/debug/tildefriends: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
out/debug/tildefriends: LDFLAGS += -fsanitize=address -fsanitize=undefined

View File

@ -113,7 +113,7 @@ typedef struct _tf_ssb_request_t
tf_ssb_callback_cleanup_t* cleanup;
void* user_data;
tf_ssb_connection_t* dependent_connection;
uint64_t last_active;
time_t last_active;
int32_t request_number;
} tf_ssb_request_t;
@ -364,7 +364,7 @@ typedef struct _tf_ssb_connection_t
int read_back_pressure;
int active_write_count;
uint64_t last_notified_active;
time_t last_notified_active;
} tf_ssb_connection_t;
static JSClassID _connection_class_id;
@ -687,35 +687,25 @@ static bool _tf_ssb_connection_get_request_callback(tf_ssb_connection_t* connect
static void _tf_ssb_request_activity_timer(uv_timer_t* timer)
{
tf_ssb_t* ssb = timer->data;
uint64_t now_ms = uv_now(ssb->loop);
bool any_still_active = false;
time_t now = time(NULL);
for (tf_ssb_connection_t* connection = ssb->connections; connection; connection = connection->next)
{
bool any_changed = false;
bool last_notified_active = (now_ms - connection->last_notified_active) < k_rpc_active_ms;
bool last_notified_active = (now - connection->last_notified_active) * 1000 < k_rpc_active_ms;
for (int i = 0; i < connection->requests_count; i++)
{
bool last_active = (now_ms - connection->requests[i].last_active) < k_rpc_active_ms;
bool last_active = (now - connection->requests[i].last_active) * 1000 <= k_rpc_active_ms;
if (last_active != last_notified_active)
{
any_changed = true;
}
if (last_active)
{
any_still_active = true;
}
}
if (any_changed)
{
_tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_update, connection);
connection->last_notified_active = now_ms;
connection->last_notified_active = now;
}
}
if (any_still_active)
{
uv_timer_start(&ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
}
}
void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, const char* name, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup,
@ -723,14 +713,14 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
{
tf_ssb_request_t* existing =
connection->requests_count ? bsearch(&request_number, connection->requests, connection->requests_count, sizeof(tf_ssb_request_t), _request_compare) : NULL;
uint64_t now_ms = uv_now(connection->ssb->loop);
time_t now = time(NULL);
if (existing)
{
assert(!existing->callback);
assert(!existing->cleanup);
assert(!existing->user_data);
assert(!existing->dependent_connection);
existing->last_active = now_ms;
existing->last_active = now;
existing->callback = callback;
existing->cleanup = cleanup;
existing->user_data = user_data;
@ -745,7 +735,7 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
.cleanup = cleanup,
.user_data = user_data,
.dependent_connection = dependent_connection,
.last_active = now_ms,
.last_active = now,
};
snprintf(request.name, sizeof(request.name), "%s", name);
int index = tf_util_insert_index(&request_number, connection->requests, connection->requests_count, sizeof(tf_ssb_request_t), _request_compare);
@ -763,7 +753,7 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
uv_timer_start(&connection->ssb->request_activity_timer, _tf_ssb_request_activity_timer, k_rpc_active_ms, 0);
}
_tf_ssb_notify_connections_changed(connection->ssb, k_tf_ssb_change_update, connection);
connection->last_notified_active = now_ms;
connection->last_notified_active = now;
}
static int _message_request_compare(const void* a, const void* b)
@ -4237,13 +4227,12 @@ JSValue tf_ssb_connection_requests_to_object(tf_ssb_connection_t* connection)
{
JSContext* context = connection->ssb->context;
JSValue object = JS_NewArray(context);
uint64_t now_ms = uv_now(connection->ssb->loop);
for (int i = 0; i < connection->requests_count; i++)
{
JSValue request = JS_NewObject(context);
JS_SetPropertyStr(context, request, "name", JS_NewString(context, connection->requests[i].name));
JS_SetPropertyStr(context, request, "request_number", JS_NewInt32(context, connection->requests[i].request_number));
JS_SetPropertyStr(context, request, "active", JS_NewBool(context, (now_ms - connection->requests[i].last_active) < k_rpc_active_ms));
JS_SetPropertyStr(context, request, "active", JS_NewBool(context, time(NULL) - connection->requests[i].last_active < 3));
JS_SetPropertyUint32(context, object, i, request);
}
return object;