Shrink code lines and reduce code cyclomatic complexity (#8748)

code cleanup in anetGenericAccept
This commit is contained in:
Andy Pan 2021-04-21 14:04:36 +08:00 committed by GitHub
parent 761d7d2771
commit 5f6e166bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -493,17 +493,12 @@ int anetUnixServer(char *err, char *path, mode_t perm, int backlog)
static int anetGenericAccept(char *err, int s, struct sockaddr *sa, socklen_t *len) { static int anetGenericAccept(char *err, int s, struct sockaddr *sa, socklen_t *len) {
int fd; int fd;
while(1) { do {
fd = accept(s,sa,len); fd = accept(s,sa,len);
if (fd == -1) { } while(fd == -1 && errno == EINTR);
if (errno == EINTR) if (fd == -1) {
continue; anetSetError(err, "accept: %s", strerror(errno));
else { return ANET_ERR;
anetSetError(err, "accept: %s", strerror(errno));
return ANET_ERR;
}
}
break;
} }
return fd; return fd;
} }