From 2ca8e9ada3a9a19c780b069aeed33fdeeb2a45ee Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 13 Dec 2023 14:40:11 +0100 Subject: [PATCH] let me try a little something... --- ipc.h | 2 +- stray_ally.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ipc.h b/ipc.h index 9e9f994..d9d8248 100644 --- a/ipc.h +++ b/ipc.h @@ -40,4 +40,4 @@ typedef struct ipc { } ipc_t; -#define SERVER_PATH "/tmp/rogue-enemy.sock" \ No newline at end of file +#define SERVER_PATH "/home/rogue-enemy.sock" \ No newline at end of file diff --git a/stray_ally.c b/stray_ally.c index 51ba18e..5322cbb 100644 --- a/stray_ally.c +++ b/stray_ally.c @@ -110,15 +110,16 @@ int main(int argc, char ** argv) { // here the client_fd is good if (pthread_mutex_lock(&dev_out_thread_data.communication.endpoint.ssocket.mutex) == 0) { - int i; - for (i = 0; i < MAX_CONNECTED_CLIENTS; ++i) { + bool found = false; + for (size_t i = 0; i < MAX_CONNECTED_CLIENTS; ++i) { if (dev_out_thread_data.communication.endpoint.ssocket.clients[i] < 0) { dev_out_thread_data.communication.endpoint.ssocket.clients[i] = client_fd; + found = true; break; } } - if (i == MAX_CONNECTED_CLIENTS) { + if (!found) { fprintf(stderr, "Could not find a free spot fot the incoming client -- client will be rejected\n"); close(client_fd); }