Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add linux accept4() support #8

Open
wants to merge 1 commit into from

2 participants

@monadbobo

Add linux accept4() support.

@thedrow

It is likely that this PR would be accepted if it had tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 12, 2012
  1. @monadbobo

    Add linux accept4() support

    monadbobo authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 0 deletions.
  1. +1 −0  configure.ac
  2. +6 −0 src/mc_core.c
View
1  configure.ac
@@ -75,6 +75,7 @@ AC_CHECK_FUNCS([mlockall])
AC_CHECK_FUNCS([getpagesizes])
AC_CHECK_FUNCS([memcntl])
AC_CHECK_FUNCS([backtrace])
+AC_CHECK_FUNCS([accept4], [AC_DEFINE(HAVE_ACCEPT4, 1, [Define to 1 if support accept4])])
# Search for library
AC_SEARCH_LIBS([pthread_create], [pthread], [],
View
6 src/mc_core.c
@@ -449,7 +449,11 @@ core_accept(struct conn *c)
ASSERT(c->state == CONN_LISTEN);
for (;;) {
+#if (HAVE_ACCEPT4)
+ sd = accept4(c->sd, NULL, NULL, SOCK_NONBLOCK);
+#else
sd = accept(c->sd, NULL, NULL);
+#endif
if (sd < 0) {
if (errno == EINTR) {
log_debug(LOG_VERB, "accept on s %d not ready - eintr", c->sd);
@@ -474,6 +478,7 @@ core_accept(struct conn *c)
break;
}
+#if !(HAVE_ACCEPT4)
status = mc_set_nonblocking(sd);
if (status != MC_OK) {
log_error("set nonblock on c %d from s %d failed: %s", sd, c->sd,
@@ -481,6 +486,7 @@ core_accept(struct conn *c)
close(sd);
return;
}
+#endif
status = mc_set_keepalive(sd);
if (status != MC_OK) {
Something went wrong with that request. Please try again.