From b7c315f355c6d54c3818c6698c57d6e6bf4f1ea9 Mon Sep 17 00:00:00 2001 From: Twaik Yont <9674930+twaik@users.noreply.github.com> Date: Mon, 10 Feb 2025 09:12:19 +0200 Subject: [PATCH] enhancement(activity.c): prevent flooding logcat with `Connection refused` messages --- app/src/main/cpp/lorie/activity.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/cpp/lorie/activity.c b/app/src/main/cpp/lorie/activity.c index 05886e3c..0432d7c5 100644 --- a/app/src/main/cpp/lorie/activity.c +++ b/app/src/main/cpp/lorie/activity.c @@ -89,6 +89,7 @@ static jboolean requestConnection(__unused JNIEnv *env, __unused jclass clazz) { check(r < 0, "poll failed: %s", strerror(errno)); socklen_t len = sizeof(so_error); check(getsockopt(sock, SOL_SOCKET, SO_ERROR, &so_error, &len) < 0, "getsockopt failed: %s", strerror(errno)); + if (so_error == ECONNREFUSED) goto end; // Regular situation which happens often if server is not started. No need to spam logcat with this. check(so_error != 0, "Connection failed: %s", strerror(so_error)); check(write(sock, MAGIC, sizeof(MAGIC)) < 0, "failed to send message: %s", strerror(errno));