From 29f67dadddfe746dc1f2d1673069d28872305fd1 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 13 Dec 2023 02:15:46 +0100 Subject: [PATCH] Do not spam errors! --- dev_out.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev_out.c b/dev_out.c index 83a75d9..ed232c8 100644 --- a/dev_out.c +++ b/dev_out.c @@ -316,11 +316,13 @@ void *dev_out_thread_func(void *ptr) { } else if (dev_out->communication.type == ipc_server_sockets) { if (pthread_mutex_lock(&dev_out->communication.endpoint.ssocket.mutex) == 0) { for (int i = 0; i < MAX_CONNECTED_CLIENTS; ++i) { - const int write_res = write(dev_out->communication.endpoint.ssocket.clients[i], (void*)&out_msgs, bytes_to_send); - if (write_res != bytes_to_send) { - fprintf(stderr, "Error in writing out_message to socket number %d: %d\n", i, write_res); - close(dev_out->communication.endpoint.ssocket.clients[i]); - dev_out->communication.endpoint.ssocket.clients[i] = -1; + if (dev_out->communication.endpoint.ssocket.clients[i] > 0) { + const int write_res = write(dev_out->communication.endpoint.ssocket.clients[i], (void*)&out_msgs, bytes_to_send); + if (write_res != bytes_to_send) { + fprintf(stderr, "Error in writing out_message to socket number %d: %d\n", i, write_res); + close(dev_out->communication.endpoint.ssocket.clients[i]); + dev_out->communication.endpoint.ssocket.clients[i] = -1; + } } }