1
0
mirror of https://github.com/fumiama/simple-http-server.git synced 2026-06-05 00:30:23 +08:00

fix accept

This commit is contained in:
源文雨
2022-03-04 19:39:21 +08:00
parent 64ec1113fd
commit 437ba41a45

View File

@@ -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);