made an accepted socket non-block
This commit is contained in:
parent
2255425b3f
commit
8eae9095c1
11
moo/configure
vendored
11
moo/configure
vendored
@ -19654,6 +19654,17 @@ _ACEOF
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for ac_func in accept4
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "accept4" "ac_cv_func_accept4"
|
||||||
|
if test "x$ac_cv_func_accept4" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_ACCEPT4 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dcNewCallVM in -ldyncall_s" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dcNewCallVM in -ldyncall_s" >&5
|
||||||
$as_echo_n "checking for dcNewCallVM in -ldyncall_s... " >&6; }
|
$as_echo_n "checking for dcNewCallVM in -ldyncall_s... " >&6; }
|
||||||
|
@ -172,6 +172,7 @@ AC_CHECK_FUNCS([gettimeofday settimeofday clock_gettime clock_settime getitimer
|
|||||||
AC_CHECK_FUNCS([backtrace backtrace_symbols])
|
AC_CHECK_FUNCS([backtrace backtrace_symbols])
|
||||||
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
|
AC_CHECK_FUNCS([makecontext swapcontext getcontext setcontext])
|
||||||
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf])
|
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf])
|
||||||
|
AC_CHECK_FUNCS([accept4])
|
||||||
|
|
||||||
AC_CHECK_LIB([dyncall_s], [dcNewCallVM],
|
AC_CHECK_LIB([dyncall_s], [dcNewCallVM],
|
||||||
[
|
[
|
||||||
|
@ -457,6 +457,8 @@ error -> exception
|
|||||||
(n asString & ' bytes read') dump.
|
(n asString & ' bytes read') dump.
|
||||||
data dump.
|
data dump.
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
sck writeBytes: #[ $h, $e, $l, $l, $o, $., $., $., C'\n' ].
|
||||||
}
|
}
|
||||||
while (true).
|
while (true).
|
||||||
].
|
].
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
/* Define if building universal (internal helper macro) */
|
/* Define if building universal (internal helper macro) */
|
||||||
#undef AC_APPLE_UNIVERSAL_BUILD
|
#undef AC_APPLE_UNIVERSAL_BUILD
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `accept4' function. */
|
||||||
|
#undef HAVE_ACCEPT4
|
||||||
|
|
||||||
/* Define to 1 if you have the `acosq' function. */
|
/* Define to 1 if you have the `acosq' function. */
|
||||||
#undef HAVE_ACOSQ
|
#undef HAVE_ACOSQ
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ static moo_pfrc_t pf_accept_socket (moo_t* moo, moo_ooi_t nargs)
|
|||||||
oop_sck_t sck, newsck;
|
oop_sck_t sck, newsck;
|
||||||
moo_oop_t arg;
|
moo_oop_t arg;
|
||||||
sck_len_t addrlen;
|
sck_len_t addrlen;
|
||||||
int fd, newfd;
|
int fd, newfd, oldfl;
|
||||||
|
|
||||||
sck = (oop_sck_t)MOO_STACK_GETRCV(moo, nargs);
|
sck = (oop_sck_t)MOO_STACK_GETRCV(moo, nargs);
|
||||||
arg = MOO_STACK_GETARG(moo, nargs, 0);
|
arg = MOO_STACK_GETARG(moo, nargs, 0);
|
||||||
@ -169,7 +169,17 @@ static moo_pfrc_t pf_accept_socket (moo_t* moo, moo_ooi_t nargs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
addrlen = MOO_OBJ_GET_SIZE(arg);
|
addrlen = MOO_OBJ_GET_SIZE(arg);
|
||||||
|
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC) && defined(HAVE_ACCEPT4)
|
||||||
|
newfd = accept4(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), &addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC);
|
||||||
|
#else
|
||||||
|
oldfl = fcntl(fd, F_GETFL, 0);
|
||||||
|
if (oldfl == -1 || fcntl(fd, F_SETFL, oldfl | O_NONBLOCK | O_CLOEXEC) == -1)
|
||||||
|
{
|
||||||
|
moo_seterrwithsyserr (moo, errno);
|
||||||
|
return MOO_PF_FAILURE;
|
||||||
|
}
|
||||||
newfd = accept(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), &addrlen);
|
newfd = accept(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), &addrlen);
|
||||||
|
#endif
|
||||||
if (newfd == -1)
|
if (newfd == -1)
|
||||||
{
|
{
|
||||||
moo_seterrwithsyserr (moo, errno);
|
moo_seterrwithsyserr (moo, errno);
|
||||||
|
Loading…
Reference in New Issue
Block a user