mirror of https://github.com/getdnsapi/getdns.git
commit
2e68f5448a
|
@ -744,6 +744,7 @@ with_gnu_ld
|
|||
with_sysroot
|
||||
enable_libtool_lock
|
||||
enable_rpath
|
||||
enable_tcp_fastopen
|
||||
with_libidn
|
||||
with_libldns
|
||||
with_libunbound
|
||||
|
@ -1380,6 +1381,7 @@ Optional Features:
|
|||
optimize for fast installation [default=yes]
|
||||
--disable-libtool-lock avoid locking (might break parallel builds)
|
||||
--disable-rpath disable hardcoded rpath (default=enabled)
|
||||
--enable-tcp-fastopen Enable TCP Fast Open
|
||||
|
||||
Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
|
@ -1752,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
|
||||
|
@ -10788,6 +10836,33 @@ if test "x$enable_rpath" = xno; then
|
|||
fi
|
||||
|
||||
|
||||
# Check whether --enable-tcp-fastopen was given.
|
||||
if test "${enable_tcp_fastopen+set}" = set; then :
|
||||
enableval=$enable_tcp_fastopen;
|
||||
fi
|
||||
|
||||
case "$enable_tcp_fastopen" in
|
||||
yes)
|
||||
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
|
||||
_ACEOF
|
||||
|
||||
;;
|
||||
no|*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# search to set include and library paths right
|
||||
# find libidn
|
||||
|
||||
|
|
|
@ -79,6 +79,18 @@ fi
|
|||
])
|
||||
ACX_ARG_RPATH
|
||||
|
||||
AC_ARG_ENABLE(tcp-fastopen, AC_HELP_STRING([--enable-tcp-fastopen], [Enable TCP Fast Open]))
|
||||
case "$enable_tcp_fastopen" in
|
||||
yes)
|
||||
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|*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# search to set include and library paths right
|
||||
# find libidn
|
||||
AC_ARG_WITH(libidn, AS_HELP_STRING([--with-libidn=pathname],
|
||||
|
|
|
@ -130,6 +130,9 @@
|
|||
/* Needed for sync stub resolver functions */
|
||||
#undef USE_MINI_EVENT
|
||||
|
||||
/* Define this to enable TCP fast open. */
|
||||
#undef USE_TCP_FASTOPEN
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
|
|
31
src/stub.c
31
src/stub.c
|
@ -802,11 +802,29 @@ 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
|
||||
*/
|
||||
#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),
|
||||
netreq->upstream->addr_len);
|
||||
/* If pipelining we will find that the connection is already up so
|
||||
just fall back to a 'normal' write. */
|
||||
if (written == -1 && errno == EISCONN)
|
||||
written = write(fd, pkt, pkt_len + 2);
|
||||
|
||||
if ((written == -1 && (errno == EAGAIN ||
|
||||
errno == EWOULDBLOCK ||
|
||||
/* Add the error case where the connection is in progress which is when
|
||||
a cookie is not available (e.g. when doing the first request to an
|
||||
upstream). We must let the handshake complete since non-blocking. */
|
||||
errno == EINPROGRESS)) ||
|
||||
written < pkt_len + 2) {
|
||||
#else
|
||||
written = write(fd, pkt, pkt_len + 2);
|
||||
if ((written == -1 && (errno == EAGAIN ||
|
||||
errno == EWOULDBLOCK)) ||
|
||||
written < pkt_len + 2) {
|
||||
|
||||
#endif
|
||||
/* We couldn't write the whole packet.
|
||||
* We have to return with STUB_TCP_AGAIN, but if
|
||||
* the packet was on the stack only, we have to copy
|
||||
|
@ -834,7 +852,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
|
|||
|
||||
} else {/* if (! tcp->write_buf) */
|
||||
|
||||
/* Coming back from an earlier unfinished write.
|
||||
/* Coming back from an earlier unfinished write or handshake.
|
||||
* Try to send remaining data */
|
||||
written = write(fd, tcp->write_buf + tcp->written,
|
||||
tcp->write_buf_len - tcp->written);
|
||||
|
@ -998,12 +1016,16 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
|||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
||||
getdns_sock_nonblock(netreq->fd);
|
||||
#ifdef USE_TCP_FASTOPEN
|
||||
/* Leave the connect to the later call to sendto() */
|
||||
#else
|
||||
if (connect(netreq->fd, (struct sockaddr *)&upstream->addr,
|
||||
upstream->addr_len) == -1 && errno != EINPROGRESS) {
|
||||
|
||||
close(netreq->fd);
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
}
|
||||
#endif
|
||||
netreq->upstream = upstream;
|
||||
|
||||
GETDNS_SCHEDULE_EVENT(
|
||||
|
@ -1025,6 +1047,10 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
|||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
||||
getdns_sock_nonblock(upstream->fd);
|
||||
#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){
|
||||
|
@ -1033,6 +1059,7 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
|||
upstream->fd = -1;
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
}
|
||||
#endif
|
||||
/* Attach to the global event loop
|
||||
* so it can do it's own scheduling
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue