From 437ba41a45726f7bc44056533eda0b87b0624afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 4 Mar 2022 19:39:21 +0800 Subject: [PATCH] fix accept --- server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.c b/server.c index 5134dea..4326f91 100644 --- a/server.c +++ b/server.c @@ -540,7 +540,10 @@ static int accept_client(int server_sock, int is_unix_sock) { pthread_attr_setdetachstate(&attr, 1); while(1) { int client_sock = accept(server_sock, (struct sockaddr *)(is_unix_sock?&uclient_name:&client_name), &client_name_len); - if(client_sock == -1) continue; + if(client_sock <= 0) { + puts("Failed to accept a client, continue..."); + continue; + } if(is_unix_sock) { uclient_name.sun_path[sizeof(uclient_name.sun_path)-1] = 0; printf("Accept client %s\n", uclient_name.sun_path);