Add detection of TFO support during configure

This commit is contained in:
saradickinson 2014-10-28 17:37:11 +00:00
parent 9d7d9997df
commit 0680e1144f
3 changed files with 63 additions and 11 deletions

61
configure vendored
View File

@ -1754,6 +1754,52 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_func
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly.
ac_fn_c_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
@ -10797,9 +10843,16 @@ fi
case "$enable_tcp_fastopen" in
yes)
# TODO: Check if it is available (linux only)
{ $as_echo "$as_me:${as_lineno-$LINENO}: TCP Fast Open enabled" >&5
$as_echo "$as_me: TCP Fast Open enabled" >&6;}
ac_fn_c_check_decl "$LINENO" "MSG_FASTOPEN" "ac_cv_have_decl_MSG_FASTOPEN" "$ac_includes_default
#include <sys/socket.h>
"
if test "x$ac_cv_have_decl_MSG_FASTOPEN" = xyes; then :
else
as_fn_error $? "TCP Fast Open is not available: please rerun without --enable-tcp-fastopen" "$LINENO" 5
fi
cat >>confdefs.h <<_ACEOF
#define USE_TCP_FASTOPEN 1
@ -10807,8 +10860,6 @@ _ACEOF
;;
no|*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: TCP Fast Open not enabled" >&5
$as_echo "$as_me: TCP Fast Open not enabled" >&6;}
;;
esac

View File

@ -82,12 +82,12 @@ ACX_ARG_RPATH
AC_ARG_ENABLE(tcp-fastopen, AC_HELP_STRING([--enable-tcp-fastopen], [Enable TCP Fast Open]))
case "$enable_tcp_fastopen" in
yes)
# TODO: Check if it is available (linux only)
AC_MSG_NOTICE([TCP Fast Open enabled])
AC_CHECK_DECL([MSG_FASTOPEN], [], [AC_MSG_ERROR([TCP Fast Open is not available: please rerun without --enable-tcp-fastopen])], [AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.])
;;
no|*)
AC_MSG_NOTICE([TCP Fast Open not enabled])
;;
esac

View File

@ -802,7 +802,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
/* We have an initialized packet buffer.
* Lets see how much of it we can write
*/
#if defined (USE_TCP_FASTOPEN) && defined(MSG_FASTOPEN)
#ifdef USE_TCP_FASTOPEN
/* We use sendto() here which will do both a connect and send */
written = sendto(fd, pkt, pkt_len + 2, MSG_FASTOPEN,
(struct sockaddr *)&(netreq->upstream->addr),
@ -1016,7 +1016,7 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
return GETDNS_RETURN_GENERIC_ERROR;
getdns_sock_nonblock(netreq->fd);
#if defined (USE_TCP_FASTOPEN) && defined(MSG_FASTOPEN)
#ifdef USE_TCP_FASTOPEN
/* Leave the connect to the later call to sendto() */
#else
if (connect(netreq->fd, (struct sockaddr *)&upstream->addr,
@ -1047,9 +1047,10 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
return GETDNS_RETURN_GENERIC_ERROR;
getdns_sock_nonblock(upstream->fd);
#if defined (USE_TCP_FASTOPEN) && defined(MSG_FASTOPEN)
#ifdef USE_TCP_FASTOPEN
/* Leave the connect to the later call to sendto() */
#else
fprintf(stderr,"connecting");
if (connect(upstream->fd,
(struct sockaddr *)&upstream->addr,
upstream->addr_len) == -1 && errno != EINPROGRESS){