mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-03 11:11:05 +00:00
utils: Wrap socket() and pipe() to reduce syscalls
Some platforms provide an implementation of socket() and pipe2() that allow the caller to specify that the resulting file descriptors should be non-blocking. Using these allows us to potentially elide 3 calls into 1 by avoiding extraneous calls to fcntl() to set the O_NONBLOCK flag afterwards. In passing, change ast_alertpipe_init() to use pipe2() directly instead of the wrapper if it is available. Change-Id: I3ebe654fb549587537161506c6c950f4ab298bb0
This commit is contained in:
23
configure.ac
23
configure.ac
@@ -784,7 +784,7 @@ AC_FUNC_STRNLEN
|
||||
AC_FUNC_STRTOD
|
||||
AC_FUNC_UTIME_NULL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim])
|
||||
AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale pipe2 ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim])
|
||||
|
||||
AC_MSG_CHECKING(for htonll)
|
||||
AC_LINK_IFELSE(
|
||||
@@ -1124,6 +1124,27 @@ AC_RUN_IFELSE(
|
||||
AC_MSG_RESULT(unknown)
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([if socket() accepts SOCK_NONBLOCK])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
], [
|
||||
if (socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0) < 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
])],
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([HAVE_SOCK_NONBLOCK], 1, [Define to 1 if your socket() implementation can accept SOCK_NONBLOCK.]),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_RESULT(cross-compile)
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING(if we can increase the maximum select-able file descriptor)
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([
|
||||
|
Reference in New Issue
Block a user