From f6a02fbe763aec5d290aa9d9509aeec5348c7792 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 29 Jun 2012 02:23:39 +0200 Subject: [PATCH] linux: don't use accept4() syscall after ENOSYS Repeatedly calling the syscall when it's not supported has a small but measurable performance impact. Besides, it's a silly thing to do. --- src/unix/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/core.c b/src/unix/core.c index 318eb718..bf429948 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -426,6 +426,11 @@ int uv__accept(int sockfd) { while (1) { #if __linux__ + static int no_accept4; + + if (no_accept4) + goto skip; + peerfd = uv__accept4(sockfd, NULL, NULL, @@ -439,6 +444,9 @@ int uv__accept(int sockfd) { if (errno != ENOSYS) break; + + no_accept4 = 1; +skip: #endif peerfd = accept(sockfd, NULL, NULL);