Merge branch 'master' of github.com:getdnsapi/getdns

This commit is contained in:
Willem Toorop 2014-10-31 14:20:39 +01:00
commit c7e7c3804a
15 changed files with 131 additions and 51 deletions

2
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# generated automatically by aclocal 1.14 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.

44
configure vendored
View File

@ -11575,6 +11575,48 @@ fi
if test x_$have_libuv = x_1; then :
EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
CHECK_UV_PROG=check_getdns_uv
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for new signature of uv_timer_cb" >&5
$as_echo_n "checking for new signature of uv_timer_cb... " >&6; }
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <uv.h>
int
main ()
{
void test_cb(uv_timer_t *handle);
uv_timer_cb cb = test_cb;
(*cb)(NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_NEW_UV_TIMER_CB 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
@ -11767,7 +11809,7 @@ fi
for ac_header in stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h time.h bsd/string.h
for ac_header in stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default

View File

@ -313,7 +313,21 @@ AS_IF([test x_$withval = x_no],
AS_IF([test x_$have_libuv = x_1],
[EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"]
[CHECK_UV_PROG=check_getdns_uv])
[CHECK_UV_PROG=check_getdns_uv]
[AC_MSG_CHECKING([for new signature of uv_timer_cb])
AC_LANG_PUSH(C)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <uv.h>]],
[[void test_cb(uv_timer_t *handle);]
[uv_timer_cb cb = test_cb;
(*cb)(NULL);]])
],[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_NEW_UV_TIMER_CB, [1], [Does libuv have the new uv_time_cb signature])
],[AC_MSG_RESULT([no])
])
AC_LANG_POP(C)]
)
AC_SUBST(have_libuv)
AC_SUBST(EXTENSION_LIBUV_LIB)
@ -407,7 +421,7 @@ dnl ----- Start of "Things needed for gldns" section
dnl -----
dnl ---------------------------------------------------------------------------
AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h time.h bsd/string.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h],,, [AC_INCLUDES_DEFAULT])
dnl Check the printf-format attribute (if any)
dnl result in HAVE_ATTR_FORMAT.
@ -454,8 +468,21 @@ AC_DEFINE(USE_MINI_EVENT, 1, [Needed for sync stub resolver functions])
AC_TYPE_SIGNAL
AH_BOTTOM([
/** Use on-board gldns */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#else
#define __BSD_VISIBLE 1
#endif
#ifdef __cplusplus
}
#endif
/** Use on-board gldns */
#define USE_GLDNS 1
#ifdef HAVE_SSL
# define GLDNS_BUILD_CONFIG_HAVE_SSL 1
@ -477,6 +504,10 @@ AH_BOTTOM([
#include <errno.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@ -523,18 +554,6 @@ AH_BOTTOM([
#ifdef HAVE_BSD_STRING_H
#include <bsd/string.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#ifdef __cplusplus
}
#endif
])
dnl ---------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ VPATH = @srcdir@
LIBTOOL = ../libtool
CC=@CC@
CFLAGS=@CFLAGS@ -Wall -I$(srcdir) -I. -std=c99 -D_POSIX_C_SOURCE=200112L
CFLAGS=-Wall -std=c99 -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -I$(srcdir) -I. @CFLAGS@
LDFLAGS=@LDFLAGS@ @LIBS@
EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@

View File

@ -60,6 +60,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Does libuv have the new uv_time_cb signature */
#undef HAVE_NEW_UV_TIMER_CB
/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
@ -78,9 +81,15 @@
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
@ -168,8 +177,21 @@
#undef uint8_t
/** Use on-board gldns */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#else
#define __BSD_VISIBLE 1
#endif
#ifdef __cplusplus
}
#endif
/** Use on-board gldns */
#define USE_GLDNS 1
#ifdef HAVE_SSL
# define GLDNS_BUILD_CONFIG_HAVE_SSL 1
@ -191,6 +213,10 @@
#include <errno.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@ -238,15 +264,3 @@
#include <bsd/string.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -704,7 +704,7 @@ getdns_context_destroy(struct getdns_context *context)
if (context->unbound_ctx)
ub_ctx_delete(context->unbound_ctx);
traverse_postorder(&context->local_hosts,
getdns_traverse_postorder(&context->local_hosts,
destroy_local_host, context);
upstreams_dereference(context->upstreams);
@ -1766,7 +1766,7 @@ cancel_outstanding_requests(struct getdns_context* context, int fire_callback) {
int i;
acc.idx = 0;
acc.ids = GETDNS_XMALLOC(context->my_mf, getdns_transaction_t, context->outbound_requests.count);
traverse_postorder(&context->outbound_requests, accumulate_outstanding_transactions, &acc);
getdns_traverse_postorder(&context->outbound_requests, accumulate_outstanding_transactions, &acc);
for (i = 0; i < acc.idx; ++i) {
getdns_context_cancel_request(context, acc.ids[i], fire_callback);
}

View File

@ -383,7 +383,7 @@ void
getdns_dict_destroy(struct getdns_dict *dict)
{
if (!dict) return;
traverse_postorder(&(dict->root), getdns_dict_item_free, dict);
getdns_traverse_postorder(&(dict->root), getdns_dict_item_free, dict);
GETDNS_FREE(dict->mf, dict);
} /* getdns_dict_destroy */

View File

@ -264,7 +264,7 @@ static void destroy_chain_link(getdns_rbnode_t * node, void *arg)
static void destroy_chain(struct validation_chain *chain)
{
traverse_postorder(&(chain->root), destroy_chain_link, chain);
getdns_traverse_postorder(&(chain->root), destroy_chain_link, chain);
GETDNS_FREE(chain->mf, chain);
}

View File

@ -31,6 +31,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <uv.h>
#include "getdns/getdns_ext_libuv.h"
#include "types-internal.h"
@ -160,7 +161,11 @@ getdns_libuv_write_cb(uv_poll_t *poll, int status, int events)
}
static void
#ifdef HAVE_NEW_UV_TIMER_CB
getdns_libuv_timeout_cb(uv_timer_t *timer)
#else
getdns_libuv_timeout_cb(uv_timer_t *timer, int status)
#endif
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data;
assert(el_ev->timeout_cb);

View File

@ -56,9 +56,9 @@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@
CHECK_EV_PROG=@CHECK_EV_PROG@
CC=@CC@
CFLAGS=@CFLAGS@ -Wall -I.. -I$(srcdir)/.. -I$(srcdir) -std=c99 $(cflags)
LDFLAGS=@LDFLAGS@ -L..
LDLIBS=-lgetdns @LIBS@ -lcheck -lm -lrt
CFLAGS=-Wall -std=c99 -I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@
LDFLAGS=@LDFLAGS@ -L..
LDLIBS=@LIBS@ ../libgetdns.la -lcheck -lm -lrt
PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync check_getdns getdns_query $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG)
.SUFFIXES: .c .o .a .lo .h
@ -98,13 +98,13 @@ check_getdns: check_getdns.lo check_getdns_common.lo check_getdns_context_set_ti
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lpthread -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo
check_getdns_event: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_event $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo
check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_uv $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo
check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_ev $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo
getdns_query: getdns_query.lo
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ getdns_query.lo

View File

@ -25,7 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <arpa/inet.h>
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -6,7 +6,8 @@ mkdir ub || true
cd ub
for f in mini_event.c mini_event.h rbtree.c rbtree.h
do
wget http://unbound.net/svn/trunk/util/$f
wget http://unbound.net/svn/trunk/util/$f || \
ftp http://unbound.net/svn/trunk/util/$f || continue
sed -e 's/event_/getdns_event_/g' \
-e 's/signal_add/getdns_signal_add/g' \
-e 's/signal_del/getdns_signal_del/g' \
@ -21,6 +22,7 @@ do
-e 's/#include "rbtree\.h"/#include "util\/rbtree.h"/g' \
-e 's/rbnode_/getdns_rbnode_/g' \
-e 's/rbtree_/getdns_rbtree_/g' \
-e 's/traverse_post/getdns_traverse_post/g' \
-e 's/#include "fptr_wlist\.h"/#include "util\/fptr_wlist.h"/g' \
-e 's/#include "log\.h"/#include "util\/log.h"/g' $f > ../$f
done

View File

@ -54,8 +54,6 @@
#if defined(USE_MINI_EVENT) && !defined(USE_WINSOCK)
#include <sys/select.h>
#ifndef HAVE_EVENT_BASE_FREE
#define HAVE_EVENT_BASE_FREE
#endif

View File

@ -602,19 +602,19 @@ getdns_rbtree_previous(getdns_rbnode_t *node)
/** recursive descent traverse */
static void
traverse_post(void (*func)(getdns_rbnode_t*, void*), void* arg, getdns_rbnode_t* node)
getdns_traverse_post(void (*func)(getdns_rbnode_t*, void*), void* arg, getdns_rbnode_t* node)
{
if(!node || node == RBTREE_NULL)
return;
/* recurse */
traverse_post(func, arg, node->left);
traverse_post(func, arg, node->right);
getdns_traverse_post(func, arg, node->left);
getdns_traverse_post(func, arg, node->right);
/* call user func */
(*func)(node, arg);
}
void
traverse_postorder(getdns_rbtree_t* tree, void (*func)(getdns_rbnode_t*, void*), void* arg)
getdns_traverse_postorder(getdns_rbtree_t* tree, void (*func)(getdns_rbnode_t*, void*), void* arg)
{
traverse_post(func, arg, tree->root);
getdns_traverse_post(func, arg, tree->root);
}

View File

@ -186,7 +186,7 @@ getdns_rbnode_t *getdns_rbtree_previous(getdns_rbnode_t *rbtree);
* The function must not alter the rbtree.
* @param arg: user argument.
*/
void traverse_postorder(getdns_rbtree_t* tree, void (*func)(getdns_rbnode_t*, void*),
void getdns_traverse_postorder(getdns_rbtree_t* tree, void (*func)(getdns_rbnode_t*, void*),
void* arg);
#endif /* UTIL_RBTREE_H_ */