Merge pull request #152 from wtoorop/devel/codebase-maintenance

Devel/codebase maintenance
This commit is contained in:
Melinda Shore 2016-03-22 20:42:57 -08:00
commit 735892cb99
29 changed files with 777 additions and 427 deletions

View File

@ -7,12 +7,11 @@ addons:
apt:
packages:
- libunbound-dev
- libldns-dev
- libidn11-dev
- check
- libevent-dev
- libev-dev
- bc
- valgrind
script:
- mkdir tests
- cd tests

View File

@ -524,6 +524,17 @@ then
AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
fi
AC_ARG_ENABLE(unbound-event-api, AC_HELP_STRING([--disable-unbound-event-api], [Disable usage of libunbounds event API]))
case "$enable_unbound_event_api" in
no)
my_enable_unbound_event_api=0
;;
yes|*)
my_enable_unbound_event_api=1
;;
esac
if test $my_with_libunbound = 1
then
AC_CHECK_HEADERS([unbound-event.h],,, [AC_INCLUDES_DEFAULT])
@ -531,9 +542,13 @@ then
AC_CHECK_LIB([unbound], [ub_fd], [
AC_DEFINE_UNQUOTED([HAVE_LIBUNBOUND], [1], [Define to 1 if you have the `unbound' library (-lunbound).]) dnl `
LIBS="-lunbound $LIBS"
AC_CHECK_FUNC([ub_ctx_create_ub_event], [
AC_DEFINE_UNQUOTED([HAVE_UNBOUND_EVENT_API], [1], [Define this when libunbound is compiled with the --enable-event-api option.])
])
if test $my_enable_unbound_event_api = 1
then
AC_CHECK_FUNC([ub_ctx_create_ub_event], [
AC_DEFINE_UNQUOTED([HAVE_UNBOUND_EVENT_API], [1], [Define this when libunbound is compiled with the --enable-event-api option.])
])
fi
AC_CHECK_FUNCS([ub_ctx_set_stub])
], [found_all_libs=0])
fi

View File

@ -149,16 +149,24 @@ depend:
# Dependencies for the examples
example-all-functions.lo example-all-functions.o: $(srcdir)/example-all-functions.c $(srcdir)/getdns_libevent.h \
../../src/config.h ../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h ../../src/getdns/getdns_extra.h
example-reverse.lo example-reverse.o: $(srcdir)/example-reverse.c $(srcdir)/getdns_libevent.h ../../src/config.h \
../../src/getdns/getdns.h $(srcdir)/../../src/getdns/getdns_ext_libevent.h \
../../src/config.h \
../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
../../src/getdns/getdns_extra.h
example-reverse.lo example-reverse.o: $(srcdir)/example-reverse.c $(srcdir)/getdns_libevent.h \
../../src/config.h \
../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
../../src/getdns/getdns_extra.h
example-simple-answers.lo example-simple-answers.o: $(srcdir)/example-simple-answers.c $(srcdir)/getdns_libevent.h \
../../src/config.h ../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h ../../src/getdns/getdns_extra.h
../../src/config.h \
../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
../../src/getdns/getdns_extra.h
example-synchronous.lo example-synchronous.o: $(srcdir)/example-synchronous.c $(srcdir)/getdns_core_only.h \
../../src/getdns/getdns.h
example-tree.lo example-tree.o: $(srcdir)/example-tree.c $(srcdir)/getdns_libevent.h ../../src/config.h \
../../src/getdns/getdns.h $(srcdir)/../../src/getdns/getdns_ext_libevent.h \
example-tree.lo example-tree.o: $(srcdir)/example-tree.c $(srcdir)/getdns_libevent.h \
../../src/config.h \
../../src/getdns/getdns.h \
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
../../src/getdns/getdns_extra.h

View File

@ -225,107 +225,189 @@ depend:
FORCE:
# Dependencies for gldns, utils, the extensions and compat functions
const-info.lo const-info.o: $(srcdir)/const-info.c getdns/getdns.h getdns/getdns_extra.h \
getdns/getdns.h $(srcdir)/const-info.h
context.lo context.o: $(srcdir)/context.c config.h $(srcdir)/debug.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
$(srcdir)/gldns/wire2str.h $(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h \
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
const-info.lo const-info.o: $(srcdir)/const-info.c \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/const-info.h
context.lo context.o: $(srcdir)/context.c \
config.h $(srcdir)/debug.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/list.h $(srcdir)/dict.h $(srcdir)/pubkey-pinning.h
convert.lo convert.o: $(srcdir)/convert.c config.h getdns/getdns.h getdns/getdns_extra.h \
getdns/getdns.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
$(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/wire2str.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/convert.h
dict.lo dict.o: $(srcdir)/dict.c config.h $(srcdir)/types-internal.h getdns/getdns.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
$(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h \
$(srcdir)/ub_loop.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h \
$(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h
dnssec.lo dnssec.o: $(srcdir)/dnssec.c config.h $(srcdir)/debug.h getdns/getdns.h $(srcdir)/context.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
convert.lo convert.o: $(srcdir)/convert.c \
config.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
$(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h \
$(srcdir)/gldns/rrdef.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/convert.h
dict.lo dict.o: $(srcdir)/dict.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
$(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h
dnssec.lo dnssec.o: $(srcdir)/dnssec.c \
config.h $(srcdir)/debug.h \
getdns/getdns.h \
$(srcdir)/context.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/dnssec.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/keyraw.h \
$(srcdir)/gldns/parseutil.h $(srcdir)/general.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/util/val_secalgo.h
general.lo general.o: $(srcdir)/general.c config.h $(srcdir)/general.h getdns/getdns.h $(srcdir)/types-internal.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/gldns/wire2str.h \
$(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h \
$(srcdir)/ub_loop.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/dict.h
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h getdns/getdns.h getdns/getdns_extra.h \
getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
$(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/list.h $(srcdir)/dict.h
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c config.h $(srcdir)/debug.h getdns/getdns.h \
$(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h $(srcdir)/types-internal.h \
$(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h config.h \
getdns/getdns_extra.h $(srcdir)/ub_loop.h
request-internal.lo request-internal.o: $(srcdir)/request-internal.c config.h $(srcdir)/types-internal.h \
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h \
getdns/getdns_extra.h $(srcdir)/ub_loop.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h \
$(srcdir)/debug.h
rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h config.h getdns/getdns.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/util-internal.h $(srcdir)/context.h getdns/getdns_extra.h getdns/getdns.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h config.h \
getdns/getdns_extra.h $(srcdir)/ub_loop.h $(srcdir)/rr-iter.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h getdns/getdns.h $(srcdir)/rr-dict.h config.h \
general.lo general.o: $(srcdir)/general.c \
config.h $(srcdir)/general.h \
getdns/getdns.h \
$(srcdir)/types-internal.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
$(srcdir)/extension/default_eventloop.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/dict.h
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
config.h $(srcdir)/context.h \
$(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/list.h $(srcdir)/dict.h
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c \
config.h $(srcdir)/debug.h \
getdns/getdns.h \
$(srcdir)/context.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h
request-internal.lo request-internal.o: $(srcdir)/request-internal.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
$(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h
rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h \
config.h \
getdns/getdns.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/util-internal.h $(srcdir)/context.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h \
getdns/getdns.h \
$(srcdir)/rr-dict.h config.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h
stub.lo stub.o: $(srcdir)/stub.c config.h $(srcdir)/debug.h $(srcdir)/stub.h getdns/getdns.h $(srcdir)/types-internal.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
$(srcdir)/gldns/wire2str.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/context.h \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
$(srcdir)/util-internal.h $(srcdir)/general.h $(srcdir)/pubkey-pinning.h
sync.lo sync.o: $(srcdir)/sync.c config.h getdns/getdns.h getdns/getdns_extra.h \
getdns/getdns.h
ub_loop.lo ub_loop.o: $(srcdir)/ub_loop.c $(srcdir)/ub_loop.h config.h getdns/getdns.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h
util-internal.lo util-internal.o: $(srcdir)/util-internal.c config.h getdns/getdns.h $(srcdir)/dict.h \
$(srcdir)/util/rbtree.h $(srcdir)/types-internal.h getdns/getdns_extra.h getdns/getdns.h \
$(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h \
getdns/getdns_extra.h $(srcdir)/ub_loop.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h
version.lo version.o: version.c
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c config.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
parse.lo parse.o: $(srcdir)/gldns/parse.c config.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h \
stub.lo stub.o: $(srcdir)/stub.c \
config.h $(srcdir)/debug.h \
$(srcdir)/stub.h \
getdns/getdns.h \
$(srcdir)/types-internal.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
$(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/util-internal.h \
$(srcdir)/general.h $(srcdir)/pubkey-pinning.h
sync.lo sync.o: $(srcdir)/sync.c \
getdns/getdns.h \
config.h $(srcdir)/context.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/debug.h $(srcdir)/general.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/gldns/wire2str.h
ub_loop.lo ub_loop.o: $(srcdir)/ub_loop.c $(srcdir)/ub_loop.h \
config.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/debug.h
util-internal.lo util-internal.o: $(srcdir)/util-internal.c \
config.h \
getdns/getdns.h \
$(srcdir)/dict.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \
getdns/getdns_extra.h \
$(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
$(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c \
config.h \
$(srcdir)/gldns/gbuffer.h
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c config.h $(srcdir)/gldns/parseutil.h
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c config.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h \
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/keyraw.h
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c config.h
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c config.h $(srcdir)/compat/chacha_private.h
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c config.h
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c config.h
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c config.h
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c config.h
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c config.h
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c \
config.h \
$(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
parse.lo parse.o: $(srcdir)/gldns/parse.c \
config.h \
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c \
config.h \
$(srcdir)/gldns/parseutil.h
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c \
config.h \
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c \
config.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c \
config.h \
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h \
$(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/keyraw.h
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c \
config.h
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c \
config.h \
$(srcdir)/compat/chacha_private.h
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c \
config.h
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c \
config.h
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c \
config.h
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c \
config.h
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c \
config.h
getentropy_win.lo getentropy_win.o: $(srcdir)/compat/getentropy_win.c
inet_ntop.lo inet_ntop.o: $(srcdir)/compat/inet_ntop.c config.h
inet_pton.lo inet_pton.o: $(srcdir)/compat/inet_pton.c config.h
sha512.lo sha512.o: $(srcdir)/compat/sha512.c config.h
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c config.h
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c config.h $(srcdir)/util/log.h $(srcdir)/debug.h config.h \
$(srcdir)/util/fptr_wlist.h $(srcdir)/util/rbtree.h
val_secalgo.lo val_secalgo.o: $(srcdir)/util/val_secalgo.c config.h $(srcdir)/util/val_secalgo.h $(srcdir)/util/log.h \
$(srcdir)/debug.h config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/gbuffer.h
inet_ntop.lo inet_ntop.o: $(srcdir)/compat/inet_ntop.c \
config.h
inet_pton.lo inet_pton.o: $(srcdir)/compat/inet_pton.c \
config.h
sha512.lo sha512.o: $(srcdir)/compat/sha512.c \
config.h
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c \
config.h
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c \
config.h \
$(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/rbtree.h
val_secalgo.lo val_secalgo.o: $(srcdir)/util/val_secalgo.c \
config.h \
$(srcdir)/util/val_secalgo.h $(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.h \
$(srcdir)/gldns/gbuffer.h
default_eventloop.lo default_eventloop.o: $(srcdir)/extension/default_eventloop.c \
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns.h \
getdns/getdns_extra.h $(srcdir)/debug.h config.h
libev.lo libev.o: $(srcdir)/extension/libev.c config.h $(srcdir)/types-internal.h getdns/getdns.h \
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
$(srcdir)/getdns/getdns_ext_libev.h getdns/getdns_extra.h
libevent.lo libevent.o: $(srcdir)/extension/libevent.c config.h $(srcdir)/types-internal.h \
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
$(srcdir)/getdns/getdns_ext_libevent.h getdns/getdns_extra.h
libuv.lo libuv.o: $(srcdir)/extension/libuv.c config.h $(srcdir)/debug.h config.h $(srcdir)/types-internal.h \
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
$(srcdir)/getdns/getdns_ext_libuv.h getdns/getdns_extra.h
$(srcdir)/extension/default_eventloop.h \
config.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/debug.h
libev.lo libev.o: $(srcdir)/extension/libev.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libev.h
libevent.lo libevent.o: $(srcdir)/extension/libevent.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libevent.h
libuv.lo libuv.o: $(srcdir)/extension/libuv.c \
config.h $(srcdir)/debug.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libuv.h

View File

@ -323,7 +323,8 @@ local_host_cmp(const void *id1, const void *id2)
return canonical_dname_compare(id1, id2);
}
static void
/** return 0 on success */
static int
add_local_host(getdns_context *context, getdns_dict *address, const char *str)
{
uint8_t host_name[256];
@ -334,7 +335,7 @@ add_local_host(getdns_context *context, getdns_dict *address, const char *str)
getdns_list **addrs;
if (gldns_str2wire_dname_buf(str, host_name, &host_name_len))
return;
return -1;
canonicalize_dname(host_name);
@ -343,7 +344,7 @@ add_local_host(getdns_context *context, getdns_dict *address, const char *str)
if (!(hnas = (host_name_addrs *)GETDNS_XMALLOC(context->mf,
uint8_t, sizeof(host_name_addrs) + host_name_len)))
return;
return -1;
hnas->ipv4addrs = NULL;
hnas->ipv6addrs = NULL;
@ -361,18 +362,23 @@ add_local_host(getdns_context *context, getdns_dict *address, const char *str)
: address_type->data[3] == '6'? &hnas->ipv4addrs : NULL)) {
if (!hnas_found) GETDNS_FREE(context->mf, hnas);
return;
return -1;
}
if (!*addrs && !(*addrs = getdns_list_create_with_context(context))) {
if (!hnas_found) GETDNS_FREE(context->mf, hnas);
return;
return -1;
}
if (_getdns_list_append_dict(*addrs, address) && !hnas_found) {
getdns_list_destroy(*addrs);
GETDNS_FREE(context->mf, hnas);
if (_getdns_list_append_this_dict(*addrs, address)) {
if (!hnas_found) {
getdns_list_destroy(*addrs);
GETDNS_FREE(context->mf, hnas);
}
return -1;
} else if (!hnas_found)
(void)_getdns_rbtree_insert(&context->local_hosts, &hnas->node);
return 0;
}
static getdns_dict *
@ -518,8 +524,8 @@ create_local_hosts(getdns_context *context)
str_addr_dict(context, start_of_word)))
/* Unparseable address */
break; /* skip to next line */
} else
add_local_host(context, address, start_of_word);
} else if (!add_local_host(context, address, start_of_word))
address = NULL;
start_of_word = NULL;
*pos = prev_c;
@ -543,7 +549,8 @@ read_more: ;
if (address) {
/* One last name for this address? */
if (start_of_word && !start_of_line)
add_local_host(context, address, start_of_word);
if (!add_local_host(context, address, start_of_word))
address = NULL;
getdns_dict_destroy(address);
}
}
@ -1442,36 +1449,45 @@ set_ub_number_opt(struct getdns_context *ctx, char *opt, uint16_t value)
static void
getdns_context_request_count_changed(getdns_context *context)
{
DEBUG_SCHED("getdns_context_request_count_changed(%d)\n",
(int) context->outbound_requests.count);
if (context->outbound_requests.count) {
if (context->ub_event.ev) return;
size_t prev_count;
DEBUG_SCHED("gc_request_count_changed "
"-> ub schedule(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev);
if (context->ub_event_scheduling) {
return;
}
context->ub_event_scheduling++;
do {
prev_count = context->outbound_requests.count;
DEBUG_SCHED("getdns_context_request_count_changed(%d)\n",
(int) context->outbound_requests.count);
if (context->outbound_requests.count && ! context->ub_event.ev){
DEBUG_SCHED("gc_request_count_changed "
"-> ub schedule(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev);
#ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API
if (!_getdns_ub_loop_enabled(&context->ub_loop))
if (!_getdns_ub_loop_enabled(&context->ub_loop))
#endif
context->extension->vmt->schedule(
context->extension, ub_fd(context->unbound_ctx),
TIMEOUT_FOREVER, &context->ub_event);
context->extension->vmt->schedule(
context->extension,
ub_fd(context->unbound_ctx),
TIMEOUT_FOREVER, &context->ub_event);
#endif
}
else if (context->ub_event.ev) /* Only test if count == 0! */ {
DEBUG_SCHED("gc_request_count_changed "
"-> ub clear(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev);
} else if (! context->outbound_requests.count &&
context->ub_event.ev) {
DEBUG_SCHED("gc_request_count_changed "
"-> ub clear(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev);
#ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API
if (!_getdns_ub_loop_enabled(&context->ub_loop))
if (!_getdns_ub_loop_enabled(&context->ub_loop))
#endif
context->extension->vmt->clear(
context->extension, &context->ub_event);
context->extension->vmt->clear(
context->extension, &context->ub_event);
#endif
}
}
} while (prev_count != context->outbound_requests.count);
context->ub_event_scheduling--;
}
void
@ -1528,6 +1544,7 @@ rebuild_ub_ctx(struct getdns_context* context) {
context->ub_event.write_cb = NULL;
context->ub_event.timeout_cb = NULL;
context->ub_event.ev = NULL;
context->ub_event_scheduling = 0;
return GETDNS_RETURN_GOOD;
}
@ -3156,87 +3173,122 @@ upstream_port(getdns_upstream *upstream)
static getdns_dict*
_get_context_settings(getdns_context* context)
{
getdns_return_t r = GETDNS_RETURN_GOOD;
getdns_dict* result = getdns_dict_create_with_context(context);
getdns_dict *result = getdns_dict_create_with_context(context);
getdns_list *list;
size_t i;
if (!result) {
return NULL;
}
/* int fields */
r = getdns_dict_set_int(result, "timeout", context->timeout);
r = getdns_dict_set_int(result, "idle_timeout", context->idle_timeout);
r |= getdns_dict_set_int(result, "limit_outstanding_queries", context->limit_outstanding_queries);
r |= getdns_dict_set_int(result, "dnssec_allowed_skew", context->dnssec_allowed_skew);
r |= getdns_dict_set_int(result, "follow_redirects", context->follow_redirects);
if (context->edns_maximum_udp_payload_size != -1)
r |= getdns_dict_set_int(result, "edns_maximum_udp_payload_size",
context->edns_maximum_udp_payload_size);
r |= getdns_dict_set_int(result, "edns_extended_rcode", context->edns_extended_rcode);
r |= getdns_dict_set_int(result, "edns_version", context->edns_version);
r |= getdns_dict_set_int(result, "edns_do_bit", context->edns_do_bit);
r |= getdns_dict_set_int(result, "append_name", context->append_name);
/* list fields */
if (!getdns_context_get_suffix(context, &list)) {
r |= getdns_dict_set_list(result, "suffix", list);
if (!result)
return NULL;
/* int fields */
if ( getdns_dict_set_int(result, "timeout",
context->timeout)
|| getdns_dict_set_int(result, "idle_timeout",
context->idle_timeout)
|| getdns_dict_set_int(result, "limit_outstanding_queries",
context->limit_outstanding_queries)
|| getdns_dict_set_int(result, "dnssec_allowed_skew",
context->dnssec_allowed_skew)
|| getdns_dict_set_int(result, "follow_redirects",
context->follow_redirects)
|| ( context->edns_maximum_udp_payload_size != -1
&& getdns_dict_set_int(result, "edns_maximum_udp_payload_size",
context->edns_maximum_udp_payload_size))
|| getdns_dict_set_int(result, "edns_extended_rcode",
context->edns_extended_rcode)
|| getdns_dict_set_int(result, "edns_version",
context->edns_version)
|| getdns_dict_set_int(result, "edns_do_bit",
context->edns_do_bit)
|| getdns_dict_set_int(result, "append_name",
context->append_name)
|| getdns_dict_set_int(result, "tls_authentication",
context->tls_auth))
goto error;
/* list fields */
if (getdns_context_get_suffix(context, &list))
goto error;
if (_getdns_dict_set_this_list(result, "suffix", list)) {
getdns_list_destroy(list);
goto error;
}
if (!getdns_context_get_upstream_recursive_servers(context, &list)) {
r |= getdns_dict_set_list(result, "upstream_recursive_servers",
list);
if (getdns_context_get_upstream_recursive_servers(context, &list))
goto error;
if (_getdns_dict_set_this_list(
result, "upstream_recursive_servers", list)) {
getdns_list_destroy(list);
goto error;
}
if (context->dns_transport_count > 0) {
if (context->dns_transport_count > 0) {
/* create a namespace list */
if (!(list = getdns_list_create_with_context(context)))
goto error;
for (i = 0; i < context->dns_transport_count; ++i) {
if (getdns_list_set_int(list, i,
context->dns_transports[i])) {
getdns_list_destroy(list);
goto error;
}
}
if (_getdns_dict_set_this_list(
result, "dns_transport_list", list)) {
getdns_list_destroy(list);
goto error;
}
}
if (context->namespace_count > 0) {
/* create a namespace list */
size_t i;
getdns_list* transports = getdns_list_create_with_context(context);
if (transports) {
for (i = 0; i < context->dns_transport_count; ++i) {
r |= getdns_list_set_int(transports, i, context->dns_transports[i]);
}
r |= getdns_dict_set_list(result, "dns_transport_list", transports);
getdns_list_destroy(transports);
}
r |= getdns_dict_set_int(result, "tls_authentication", context->tls_auth);
}
if (context->namespace_count > 0) {
/* create a namespace list */
size_t i;
getdns_list* namespaces = getdns_list_create_with_context(context);
if (namespaces) {
for (i = 0; i < context->namespace_count; ++i) {
r |= getdns_list_set_int(namespaces, i, context->namespaces[i]);
}
r |= getdns_dict_set_list(result, "namespaces", namespaces);
getdns_list_destroy(namespaces);
}
}
if (r != GETDNS_RETURN_GOOD) {
getdns_dict_destroy(result);
result = NULL;
}
return result;
if (!(list = getdns_list_create_with_context(context)))
goto error;
for (i = 0; i < context->namespace_count; ++i) {
if (getdns_list_set_int(list, i,
context->namespaces[i])) {
getdns_list_destroy(list);
goto error;
}
}
if (_getdns_dict_set_this_list(result, "namespaces", list)) {
getdns_list_destroy(list);
return NULL;
}
}
return result;
error:
getdns_dict_destroy(result);
return NULL;
}
getdns_dict*
getdns_context_get_api_information(getdns_context* context) {
getdns_return_t r = GETDNS_RETURN_GOOD;
getdns_dict* result = getdns_dict_create_with_context(context);
getdns_dict* settings;
if (!result) {
return NULL;
}
r = getdns_dict_util_set_string(result, "version_string", GETDNS_VERSION);
r |= getdns_dict_util_set_string(result, "implementation_string", PACKAGE_URL);
r |= getdns_dict_set_int(result, "resolution_type", context->resolution_type);
settings = _get_context_settings(context);
r |= getdns_dict_set_dict(result, "all_context", settings);
getdns_dict_destroy(settings);
if (r != GETDNS_RETURN_GOOD) {
getdns_dict_destroy(result);
result = NULL;
}
return result;
getdns_context_get_api_information(getdns_context* context)
{
getdns_dict* result;
getdns_dict* settings;
if ((result = getdns_dict_create_with_context(context))
&& ! getdns_dict_util_set_string(
result, "version_string", GETDNS_VERSION)
&& ! getdns_dict_util_set_string(
result, "implementation_string", PACKAGE_URL)
&& ! getdns_dict_set_int(
result, "resolution_type", context->resolution_type)
&& (settings = _get_context_settings(context))) {
if (!_getdns_dict_set_this_dict(result,"all_context",settings))
return result;
getdns_dict_destroy(settings);
}
getdns_dict_destroy(result);
return NULL;
}
getdns_return_t
@ -3336,17 +3388,17 @@ _getdns_context_local_namespace_resolve(
}
if (!(jaa = getdns_list_create_with_context(context)))
goto error;
for (i = 0; !getdns_list_get_dict(hnas->ipv4addrs, i, &addr); i++)
if (_getdns_list_append_dict(jaa, addr))
break;
for (i = 0; !getdns_list_get_dict(hnas->ipv6addrs, i, &addr); i++)
if (_getdns_list_append_dict(jaa, addr))
break;
if (!getdns_dict_set_list(*response, "just_address_answers", jaa)) {
getdns_list_destroy(jaa);
if (!_getdns_dict_set_this_list(*response, "just_address_answers", jaa))
return GETDNS_RETURN_GOOD;
}
getdns_list_destroy(jaa);
else
getdns_list_destroy(jaa);
error:
getdns_dict_destroy(*response);
return GETDNS_RETURN_GENERIC_ERROR;
@ -3652,14 +3704,16 @@ getdns_context_get_upstream_recursive_servers(getdns_context *context,
if ((_getdns_get_pubkey_pinset_list(context,
upstream->tls_pubkey_pinset,
&pins) == GETDNS_RETURN_GOOD) &&
(r = getdns_dict_set_list(d, "tls_pubkey_pinset", pins)))
(r = _getdns_dict_set_this_list(d, "tls_pubkey_pinset", pins))) {
getdns_list_destroy(pins);
break;
getdns_list_destroy(pins);
}
}
}
}
if (!r)
r = _getdns_list_append_dict(upstreams, d);
if (!(r = _getdns_list_append_this_dict(upstreams, d)))
d = NULL;
getdns_dict_destroy(d);
}
if (r)

View File

@ -248,6 +248,8 @@ struct getdns_context {
#ifdef HAVE_LIBUNBOUND
getdns_eventloop_event ub_event;
/* lock to prevent nested ub_event scheduling */
int ub_event_scheduling;
#endif
/* The default extension */

View File

@ -567,8 +567,8 @@ _getdns_fp2rr_list(struct mem_funcs *mf,
continue;
if ((r = _getdns_wire2rr_dict(mf, rr, len, &rr_dict)))
break;
r = _getdns_list_append_dict(rrs, rr_dict);
getdns_dict_destroy(rr_dict);
if ((r = _getdns_list_append_this_dict(rrs, rr_dict)))
getdns_dict_destroy(rr_dict);
}
if (rr)
GETDNS_FREE(*mf, rr);
@ -637,9 +637,8 @@ _getdns_wire2msg_dict_scan(struct mem_funcs *mf,
SET_WIRE_CNT(arcount, ARCOUNT);
/* header */
if ((r = getdns_dict_set_dict(result, "header", header)))
if ((r = _getdns_dict_set_this_dict(result, "header", header)))
goto error;
getdns_dict_destroy(header);
header = NULL;
eop = *wire + 12;
@ -655,25 +654,32 @@ _getdns_wire2msg_dict_scan(struct mem_funcs *mf,
switch ((section = _getdns_rr_iter_section(rr_iter))) {
case GLDNS_SECTION_QUESTION:
if ((r = getdns_dict_set_dict(
if ((r = _getdns_dict_set_this_dict(
result, "question", rr_dict)))
goto error;
break;
default:
if ((r = _getdns_list_append_dict(
if ((r = _getdns_list_append_this_dict(
sections[section], rr_dict)))
goto error;
break;
}
rr_dict = NULL;
}
if ((r = getdns_dict_set_list(result, "answer",
sections[GLDNS_SECTION_ANSWER])) ||
(r = getdns_dict_set_list(result, "authority",
sections[GLDNS_SECTION_AUTHORITY])) ||
(r = getdns_dict_set_list(result, "additional",
sections[GLDNS_SECTION_ADDITIONAL])))
goto error;
if (!(r = _getdns_dict_set_this_list(result, "answer",
sections[GLDNS_SECTION_ANSWER])))
sections[GLDNS_SECTION_ANSWER] = NULL;
else goto error;
if (!(r = _getdns_dict_set_this_list(result, "authority",
sections[GLDNS_SECTION_AUTHORITY])))
sections[GLDNS_SECTION_AUTHORITY] = NULL;
else goto error;
if (!(r = _getdns_dict_set_this_list(result, "additional",
sections[GLDNS_SECTION_ADDITIONAL])))
sections[GLDNS_SECTION_ADDITIONAL] = NULL;
else goto error;
*wire_len -= (eop - *wire);
*wire = eop;

View File

@ -530,51 +530,75 @@ getdns_dict_destroy(struct getdns_dict *dict)
/*---------------------------------------- getdns_dict_set_dict */
getdns_return_t
getdns_dict_set_dict(
getdns_dict *dict, const char *name, const getdns_dict *child_dict)
_getdns_dict_set_this_dict(
getdns_dict *dict, const char *name, getdns_dict *child_dict)
{
getdns_item *item;
getdns_dict *newdict;
getdns_return_t r;
if (!dict || !name || !child_dict)
return GETDNS_RETURN_INVALID_PARAMETER;
if ((r = _getdns_dict_copy(child_dict, &newdict)))
if ((r = _getdns_dict_find_and_add(dict, name, &item)))
return r;
if ((r = _getdns_dict_find_and_add(dict, name, &item))) {
getdns_dict_destroy(newdict);
return r;
}
item->dtype = t_dict;
item->data.dict = newdict;
item->data.dict = child_dict;
return GETDNS_RETURN_GOOD;
} /* getdns_dict_set_dict */
getdns_return_t
getdns_dict_set_dict(
getdns_dict *dict, const char *name, const getdns_dict *child_dict)
{
getdns_dict *newdict;
getdns_return_t r;
if ((r = _getdns_dict_copy(child_dict, &newdict)))
return r;
if ((r = _getdns_dict_set_this_dict(dict, name, newdict)))
getdns_dict_destroy(newdict);
return r;
}
/*---------------------------------------- getdns_dict_set_list */
getdns_return_t
getdns_dict_set_list(
getdns_dict *dict, const char *name, const getdns_list *child_list)
_getdns_dict_set_this_list(
getdns_dict *dict, const char *name, getdns_list *child_list)
{
getdns_item *item;
getdns_list *newlist;
getdns_return_t r;
if (!dict || !name || !child_list)
return GETDNS_RETURN_INVALID_PARAMETER;
if ((r = _getdns_dict_find_and_add(dict, name, &item)))
return r;
item->dtype = t_list;
item->data.list = child_list;
return GETDNS_RETURN_GOOD;
} /* getdns_dict_set_list */
getdns_return_t
getdns_dict_set_list(
getdns_dict *dict, const char *name, const getdns_list *child_list)
{
getdns_list *newlist;
getdns_return_t r;
if ((r = _getdns_list_copy(child_list, &newlist)))
return r;
if ((r = _getdns_dict_find_and_add(dict, name, &item))) {
if ((r = _getdns_dict_set_this_list(dict, name, newlist)))
getdns_list_destroy(newlist);
return r;
}
item->dtype = t_list;
item->data.list = newlist;
return GETDNS_RETURN_GOOD;
} /* getdns_dict_set_list */
return r;
}
/*---------------------------------------- getdns_dict_set_bindata */
getdns_return_t
@ -598,7 +622,7 @@ _getdns_dict_set_const_bindata(
item->dtype = t_bindata;
item->data.bindata = newbindata;
return GETDNS_RETURN_GOOD;
} /* getdns_dict_set_bindata */
}
getdns_return_t
getdns_dict_set_bindata(

View File

@ -3079,8 +3079,8 @@ static void append_rrs2val_chain_list(getdns_context *ctxt,
&ctxt->mf, &rr->rr_i)))
continue;
(void)_getdns_list_append_dict(val_chain_list, rr_dict);
getdns_dict_destroy(rr_dict);
if (_getdns_list_append_this_dict(val_chain_list, rr_dict))
getdns_dict_destroy(rr_dict);
}
for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset)
; rrsig; rrsig = rrsig_iter_next(rrsig)) {
@ -3098,8 +3098,8 @@ static void append_rrs2val_chain_list(getdns_context *ctxt,
&ctxt->mf, &rrsig->rr_i)))
continue;
(void)_getdns_list_append_dict(val_chain_list, rr_dict);
getdns_dict_destroy(rr_dict);
if (_getdns_list_append_this_dict(val_chain_list, rr_dict))
getdns_dict_destroy(rr_dict);
}
}
}
@ -3130,8 +3130,8 @@ static void append_empty_ds2val_chain_list(
(void) getdns_dict_set_bindata(rdata_dict, "rdata_raw", &bindata);
getdns_dict_destroy(rdata_dict);
(void)_getdns_list_append_dict(val_chain_list, rr_dict);
getdns_dict_destroy(rr_dict);
if (_getdns_list_append_this_dict(val_chain_list, rr_dict))
getdns_dict_destroy(rr_dict);
}
static void check_chain_complete(chain_head *chain)
@ -3239,9 +3239,9 @@ static void check_chain_complete(chain_head *chain)
response_dict = _getdns_create_getdns_response(dnsreq);
if (val_chain_list) {
(void) getdns_dict_set_list(
response_dict, "validation_chain", val_chain_list);
getdns_list_destroy(val_chain_list);
if (_getdns_dict_set_this_list(
response_dict, "validation_chain", val_chain_list))
getdns_list_destroy(val_chain_list);
}
/* Final user callback */

View File

@ -60,16 +60,23 @@ default_eventloop_schedule(getdns_eventloop *loop,
, fd, FD_SETSIZE);
return GETDNS_RETURN_GENERIC_ERROR;
}
if (fd >= 0 && !(event->read_cb || event->write_cb)) {
DEBUG_SCHED("WARNING: fd event without "
"read or write cb!\n");
fd = -1;
}
if (fd >= 0) {
if (!(event->read_cb || event->write_cb)) {
DEBUG_SCHED("ERROR: fd event without "
"read or write cb!\n");
return GETDNS_RETURN_GENERIC_ERROR;
}
#if defined(SCHED_DEBUG) && SCHED_DEBUG
if (default_loop->fd_events[fd]) {
DEBUG_SCHED( "ERROR: Event present at fd slot: %p!\n"
, default_loop->fd_events[fd]);
if (default_loop->fd_events[fd] == event) {
DEBUG_SCHED("WARNING: Event %p not cleared "
"before being rescheduled!\n"
, default_loop->fd_events[fd]);
} else {
DEBUG_SCHED("ERROR: A different event is "
"already present at fd slot: %p!\n"
, default_loop->fd_events[fd]);
}
}
#endif
default_loop->fd_events[fd] = event;

View File

@ -335,22 +335,23 @@ _getdns_list_copy(const struct getdns_list * srclist,
switch (srclist->items[i].dtype) {
case t_int:
retval = _getdns_list_append_int(*dstlist,
srclist->items[i].data.n);
srclist->items[i].data.n);
break;
case t_list:
retval = _getdns_list_append_list(*dstlist,
srclist->items[i].data.list);
retval = getdns_list_set_list(*dstlist,
(*dstlist)->numinuse, srclist->items[i].data.list);
break;
case t_bindata:
retval = _getdns_list_append_bindata(*dstlist,
srclist->items[i].data.bindata);
retval = _getdns_list_append_const_bindata(*dstlist,
srclist->items[i].data.bindata->size,
srclist->items[i].data.bindata->data);
break;
case t_dict:
retval = _getdns_list_append_dict(*dstlist,
srclist->items[i].data.dict);
srclist->items[i].data.dict);
break;
}
if (retval != GETDNS_RETURN_GOOD) {
@ -506,6 +507,23 @@ _getdns_list_request_index(getdns_list *list, size_t index)
}
/*---------------------------------------- getdns_list_set_dict */
static getdns_return_t
_getdns_list_set_this_dict(
getdns_list *list, size_t index, getdns_dict *child_dict)
{
getdns_return_t r;
if (!list || !child_dict)
return GETDNS_RETURN_INVALID_PARAMETER;
if ((r = _getdns_list_request_index(list, index)))
return r;
list->items[index].dtype = t_dict;
list->items[index].data.dict = child_dict;
return GETDNS_RETURN_GOOD;
} /* getdns_list_set_dict */
getdns_return_t
getdns_list_set_dict(
getdns_list *list, size_t index, const getdns_dict *child_dict)
@ -519,13 +537,10 @@ getdns_list_set_dict(
if ((r = _getdns_dict_copy(child_dict, &newdict)))
return r;
if ((r = _getdns_list_request_index(list, index))) {
if ((r = _getdns_list_set_this_dict(list, index, newdict)))
getdns_dict_destroy(newdict);
return r;
}
list->items[index].dtype = t_dict;
list->items[index].data.dict = newdict;
return GETDNS_RETURN_GOOD;
return r;
} /* getdns_list_set_dict */
/*---------------------------------------- getdns_list_set_list */
@ -616,16 +631,10 @@ _getdns_list_append_dict(getdns_list *list, const getdns_dict *child_dict)
return getdns_list_set_dict(list, list->numinuse, child_dict);
}
getdns_return_t
_getdns_list_append_list(getdns_list *list, const getdns_list *child_list)
_getdns_list_append_this_dict(getdns_list *list, getdns_dict *child_dict)
{
if (!list) return GETDNS_RETURN_INVALID_PARAMETER;
return getdns_list_set_list(list, list->numinuse, child_list);
}
getdns_return_t
_getdns_list_append_bindata(getdns_list *list, const getdns_bindata *child_bindata)
{
if (!list) return GETDNS_RETURN_INVALID_PARAMETER;
return getdns_list_set_bindata(list, list->numinuse, child_bindata);
return _getdns_list_set_this_dict(list, list->numinuse, child_dict);
}
getdns_return_t
_getdns_list_append_const_bindata(

View File

@ -54,6 +54,7 @@
#include <openssl/x509.h>
#include <string.h>
#include "context.h"
#include "util-internal.h"
/* we only support sha256 at the moment. adding support for another
digest is more complex than just adding another entry here. in
@ -156,11 +157,9 @@ getdns_dict* getdns_pubkey_pin_create_from_string(
*/
#define PKP_SC_ERR(e) { \
err.size = sizeof(e); \
err.data = (uint8_t*)e; \
if (errorlist) \
getdns_list_set_bindata(errorlist, \
preverrs + errorcount, &err); \
_getdns_list_append_const_bindata(errorlist, \
sizeof(e), e); \
errorcount++; \
}
#define PKP_SC_HARDERR(e, val) { \
@ -170,15 +169,10 @@ getdns_return_t getdns_pubkey_pinset_sanity_check(
const getdns_list* pinset,
getdns_list* errorlist)
{
size_t errorcount = 0, preverrs = 0, pins = 0, i;
getdns_bindata err;
size_t errorcount = 0, pins = 0, i;
getdns_dict * pin;
getdns_bindata * data;
if (errorlist)
if (getdns_list_get_length(errorlist, &preverrs))
return GETDNS_RETURN_INVALID_PARAMETER;
if (getdns_list_get_length(pinset, &pins))
PKP_SC_HARDERR("Can't get length of pinset",
GETDNS_RETURN_INVALID_PARAMETER);
@ -281,7 +275,6 @@ _getdns_get_pubkey_pinset_list(getdns_context *ctx,
uint8_t buf[SHA256_DIGEST_LENGTH];
getdns_bindata value = { .size = SHA256_DIGEST_LENGTH, .data = buf };
getdns_dict *pin = NULL;
size_t idx = 0;
if (out == NULL)
return GETDNS_RETURN_MEMORY_ERROR;
@ -296,9 +289,8 @@ _getdns_get_pubkey_pinset_list(getdns_context *ctx,
memcpy(buf, pinset_in->pin, sizeof(buf));
if (r = getdns_dict_set_bindata(pin, "value", &value), r)
goto fail;
if (r = getdns_list_set_dict(out, idx++, pin), r)
if (r = _getdns_list_append_this_dict(out, pin), r)
goto fail;
getdns_dict_destroy(pin);
pin = NULL;
pinset_in = pinset_in->next;
}

View File

@ -845,6 +845,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
}
} else if (result->append_name ==
GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE &&
result->name[0] &&
result->name[result->name[0]+1] != 0) {
/* We have multiple labels, no appending */
result->suffix_len = no_suffixes[0];

View File

@ -1823,7 +1823,7 @@ upstream_reschedule_events(getdns_upstream *upstream, size_t idle_timeout) {
upstream->event.timeout_cb = upstream_idle_timeout_cb;
if (upstream->tcp.write_error != 0)
idle_timeout = 0;
GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd,
GETDNS_SCHEDULE_EVENT(upstream->loop, -1,
idle_timeout, &upstream->event);
}
}
@ -1985,7 +1985,10 @@ _getdns_submit_stub_request(getdns_network_req *netreq)
* to begin with) worth the complexity of divergent code paths?
*/
GETDNS_SCHEDULE_EVENT(
dnsreq->loop, netreq->upstream->fd, /*dnsreq->context->timeout,*/
dnsreq->loop,
( dnsreq->loop != netreq->upstream->loop /* Synchronous lookup? */
? netreq->upstream->fd : -1),
/*dnsreq->context->timeout,*/
(transport == GETDNS_TRANSPORT_TLS ?
dnsreq->context->timeout /2 : dnsreq->context->timeout),
getdns_eventloop_event_init(&netreq->event, netreq, NULL,

View File

@ -57,9 +57,7 @@ typedef struct getdns_sync_data {
static getdns_return_t
getdns_sync_data_init(getdns_context *context, getdns_sync_data *data)
{
#ifdef HAVE_LIBUNBOUND
getdns_eventloop *ext = &context->sync_eventloop.loop;
#endif
data->context = context;
data->to_run = 1;
@ -145,6 +143,7 @@ getdns_general_sync(getdns_context *context, const char *name,
return r;
}
getdns_sync_loop_run(&data);
getdns_sync_data_cleanup(&data);
return (*response = data.response) ?
GETDNS_RETURN_GOOD : GETDNS_RETURN_GENERIC_ERROR;
@ -170,6 +169,7 @@ getdns_address_sync(getdns_context *context, const char *name,
return r;
}
getdns_sync_loop_run(&data);
getdns_sync_data_cleanup(&data);
return (*response = data.response) ?
GETDNS_RETURN_GOOD : GETDNS_RETURN_GENERIC_ERROR;
@ -195,6 +195,7 @@ getdns_hostname_sync(getdns_context *context, getdns_dict *address,
return r;
}
getdns_sync_loop_run(&data);
getdns_sync_data_cleanup(&data);
return (*response = data.response) ?
GETDNS_RETURN_GOOD : GETDNS_RETURN_GENERIC_ERROR;
@ -220,6 +221,7 @@ getdns_service_sync(getdns_context *context, const char *name,
return r;
}
getdns_sync_loop_run(&data);
getdns_sync_data_cleanup(&data);
return (*response = data.response) ?
GETDNS_RETURN_GOOD : GETDNS_RETURN_GENERIC_ERROR;

View File

@ -153,10 +153,12 @@ nolibcheck:
test: $(NOLIBCHECK) all
(cd $(srcdir)/../.. && find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | awk 'BEGIN{e=0}{print("ERROR! Executable bit found on", $$0);e=1}END{exit(e)}')
./$(CHECK_GETDNS)
if test $(have_libevent) = 1 ; then ./$(CHECK_EVENT_PROG) ; fi
if test $(have_libev) = 1 ; then ./$(CHECK_EV_PROG) ; fi
if test $(have_libuv) = 1 ; then ./$(CHECK_UV_PROG) ; fi
rm -f fails
CK_LOG_FILE_NAME="$(CHECK_GETDNS).log" ./$(CHECK_GETDNS) || echo "$(CHECK_GETDNS) failed" >> fails
if test $(have_libevent) = 1 ; then CK_LOG_FILE_NAME="$(CHECK_EVENT_PROG).log" ./$(CHECK_EVENT_PROG) || echo "$(CHECK_EVENT_PROG) failed" >> fails; fi
if test $(have_libev) = 1 ; then CK_LOG_FILE_NAME="$(CHECK_EV_PROG).log" ./$(CHECK_EV_PROG) || echo "$(CHECK_EV_PROG) failed" >> fails; fi
if test $(have_libuv) = 1 ; then CK_LOG_FILE_NAME="$(CHECK_UV_PROG).log" ./$(CHECK_UV_PROG) || echo "$(CHECK_UV_PROG) failed" >> fails; fi
test ! -e fails
@echo "All tests OK"
clean:
@ -219,21 +221,24 @@ depend:
.PHONY: clean test
# Dependencies for the unit tests
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(srcdir)/check_getdns_common.h \
../getdns/getdns_extra.h $(srcdir)/check_getdns_general.h \
$(srcdir)/check_getdns_general_sync.h $(srcdir)/check_getdns_address.h \
$(srcdir)/check_getdns_address_sync.h $(srcdir)/check_getdns_hostname.h \
$(srcdir)/check_getdns_hostname_sync.h $(srcdir)/check_getdns_context_create.h \
$(srcdir)/check_getdns_context_destroy.h $(srcdir)/check_getdns_cancel_callback.h \
$(srcdir)/check_getdns_list_get_length.h $(srcdir)/check_getdns_list_get_data_type.h \
$(srcdir)/check_getdns_list_get_dict.h $(srcdir)/check_getdns_list_get_list.h \
$(srcdir)/check_getdns_list_get_int.h $(srcdir)/check_getdns_list_get_bindata.h \
$(srcdir)/check_getdns_dict_get_names.h $(srcdir)/check_getdns_dict_get_data_type.h \
$(srcdir)/check_getdns_dict_get_dict.h $(srcdir)/check_getdns_dict_get_list.h \
$(srcdir)/check_getdns_dict_get_bindata.h $(srcdir)/check_getdns_dict_get_int.h \
$(srcdir)/check_getdns_dict_destroy.h $(srcdir)/check_getdns_dict_set_dict.h \
$(srcdir)/check_getdns_dict_set_list.h $(srcdir)/check_getdns_dict_set_bindata.h \
$(srcdir)/check_getdns_dict_set_int.h $(srcdir)/check_getdns_convert_ulabel_to_alabel.h \
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c \
../getdns/getdns.h \
$(srcdir)/check_getdns_common.h \
../getdns/getdns_extra.h \
$(srcdir)/check_getdns_general.h $(srcdir)/check_getdns_general_sync.h \
$(srcdir)/check_getdns_address.h $(srcdir)/check_getdns_address_sync.h \
$(srcdir)/check_getdns_hostname.h $(srcdir)/check_getdns_hostname_sync.h \
$(srcdir)/check_getdns_context_create.h $(srcdir)/check_getdns_context_destroy.h \
$(srcdir)/check_getdns_cancel_callback.h $(srcdir)/check_getdns_list_get_length.h \
$(srcdir)/check_getdns_list_get_data_type.h $(srcdir)/check_getdns_list_get_dict.h \
$(srcdir)/check_getdns_list_get_list.h $(srcdir)/check_getdns_list_get_int.h \
$(srcdir)/check_getdns_list_get_bindata.h $(srcdir)/check_getdns_dict_get_names.h \
$(srcdir)/check_getdns_dict_get_data_type.h $(srcdir)/check_getdns_dict_get_dict.h \
$(srcdir)/check_getdns_dict_get_list.h $(srcdir)/check_getdns_dict_get_bindata.h \
$(srcdir)/check_getdns_dict_get_int.h $(srcdir)/check_getdns_dict_destroy.h \
$(srcdir)/check_getdns_dict_set_dict.h $(srcdir)/check_getdns_dict_set_list.h \
$(srcdir)/check_getdns_dict_set_bindata.h $(srcdir)/check_getdns_dict_set_int.h \
$(srcdir)/check_getdns_convert_ulabel_to_alabel.h \
$(srcdir)/check_getdns_convert_alabel_to_ulabel.h $(srcdir)/check_getdns_pretty_print_dict.h \
$(srcdir)/check_getdns_display_ip_address.h \
$(srcdir)/check_getdns_context_set_context_update_callback.h \
@ -241,36 +246,63 @@ check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(sr
$(srcdir)/check_getdns_context_set_upstream_recursive_servers.h \
$(srcdir)/check_getdns_service.h $(srcdir)/check_getdns_service_sync.h \
$(srcdir)/check_getdns_transport.h
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c ../getdns/getdns.h \
../config.h $(srcdir)/check_getdns_common.h ../getdns/getdns_extra.h \
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c \
../getdns/getdns.h \
../config.h \
$(srcdir)/check_getdns_common.h \
../getdns/getdns_extra.h \
$(srcdir)/check_getdns_eventloop.h
check_getdns_context_set_timeout.lo check_getdns_context_set_timeout.o: $(srcdir)/check_getdns_context_set_timeout.c \
$(srcdir)/check_getdns_context_set_timeout.h $(srcdir)/check_getdns_common.h \
../getdns/getdns.h ../getdns/getdns_extra.h
../getdns/getdns.h \
../getdns/getdns_extra.h
check_getdns_libev.lo check_getdns_libev.o: $(srcdir)/check_getdns_libev.c $(srcdir)/check_getdns_eventloop.h \
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libev.h \
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
../config.h \
../getdns/getdns.h \
$(srcdir)/../getdns/getdns_ext_libev.h \
../getdns/getdns_extra.h \
$(srcdir)/check_getdns_common.h
check_getdns_libevent.lo check_getdns_libevent.o: $(srcdir)/check_getdns_libevent.c $(srcdir)/check_getdns_eventloop.h \
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libevent.h \
../getdns/getdns_extra.h $(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
../config.h \
../getdns/getdns.h \
$(srcdir)/../getdns/getdns_ext_libevent.h \
../getdns/getdns_extra.h \
$(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
check_getdns_libuv.lo check_getdns_libuv.o: $(srcdir)/check_getdns_libuv.c $(srcdir)/check_getdns_eventloop.h \
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libuv.h \
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
../config.h \
../getdns/getdns.h \
$(srcdir)/../getdns/getdns_ext_libuv.h \
../getdns/getdns_extra.h \
$(srcdir)/check_getdns_common.h
check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_selectloop.c \
$(srcdir)/check_getdns_eventloop.h ../config.h ../getdns/getdns.h \
$(srcdir)/check_getdns_eventloop.h \
../config.h \
../getdns/getdns.h \
../getdns/getdns_extra.h
check_getdns_transport.lo check_getdns_transport.o: $(srcdir)/check_getdns_transport.c \
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h ../getdns/getdns.h \
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h \
../getdns/getdns.h \
../getdns/getdns_extra.h
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h $(srcdir)/../debug.h ../config.h \
../getdns/getdns.h ../getdns/getdns_extra.h
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/getdns.h \
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c \
../config.h \
$(srcdir)/../debug.h \
../getdns/getdns.h \
../getdns/getdns_extra.h
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c \
../getdns/getdns.h \
../getdns/getdns_extra.h
testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h ../getdns/getdns.h
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h ../getdns/getdns.h
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h ../getdns/getdns.h
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c ../config.h $(srcdir)/testmessages.h \
../getdns/getdns.h ../getdns/getdns_extra.h
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h ../getdns/getdns.h \
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h \
../getdns/getdns.h
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h \
../getdns/getdns.h
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h \
../getdns/getdns.h
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c \
../config.h \
$(srcdir)/testmessages.h \
../getdns/getdns.h \
../getdns/getdns_extra.h
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h \
../getdns/getdns.h \
../getdns/getdns_extra.h

View File

@ -20,3 +20,10 @@ A typical flow might be illustrated via tests_list:
Some of the tests that remain to be implemented:
- memory leak testing integrated into the test progs
libcheck facilitates selectively debugging of specific cases.
Example usage:
$ CK_LOG_FILE_NAME="/dev/stderr" CK_FORK=no \
CK_RUN_SUITE="getdns_context_set_timeout()" CK_RUN_CASE="Positive" \
../../libtool exe gdb --args ./check_getdns

View File

@ -76,7 +76,6 @@ main (int argc, char** argv)
{
int number_failed;
SRunner *sr ;
char log_fn[1024], *exe_fn;
Suite *getdns_general_suite(void);
Suite *getdns_general_sync_suite(void);
@ -153,20 +152,6 @@ main (int argc, char** argv)
srunner_add_suite(sr,getdns_service_sync_suite());
srunner_add_suite(sr,getdns_transport_suite());
if ((exe_fn = strrchr(argv[0], '/')) && *exe_fn) {
exe_fn += 1;
if (exe_fn[0] == 'l' && exe_fn[1] == 't' && exe_fn[2] == '-') {
exe_fn += 3;
}
if (strlen(strncpy(log_fn, exe_fn, sizeof(log_fn) - 1)) < sizeof(log_fn) - 5) {
(void) strncat(log_fn, ".log", 4);
srunner_set_log(sr, log_fn);
}
else
srunner_set_log(sr, "check_getdns.log");
}
else
srunner_set_log(sr, "check_getdns.log");
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);

View File

@ -1219,6 +1219,7 @@ getdns_return_t do_the_call(void)
if (r != GETDNS_RETURN_GOOD) {
fprintf(stderr, "An error occurred: %d '%s'\n", (int)r,
getdns_get_errorstr_by_id(r));
getdns_dict_destroy(address);
return r;
}
if (response && !quiet) {
@ -1242,6 +1243,7 @@ getdns_return_t do_the_call(void)
if (response)
getdns_dict_destroy(response);
}
getdns_dict_destroy(address);
return r;
}

View File

@ -0,0 +1 @@
. DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5

View File

@ -0,0 +1,16 @@
BaseName: 125-valgrind-checks
Version: 1.0
Description: Run valgrind to detect memory leaks
CreationDate: ma mrt 21 15:59:59 CET 2016
Maintainer: Willem Toorop
Category:
Component:
CmdDepends:
Depends: 110-link.tpkg
Help:
Pre:
Post:
Test: 125-valgrind-checks.test
AuxFiles:
Passed:
Failure:

View File

@ -0,0 +1,26 @@
# #-- 125-valgrind-checks.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
cat >queries <<EOT
NS .
-A getdnsapi.net
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
-G TXT bogus.nlnetlabs.nl
-H 8.8.8.8
-H 2a04:b900:0:100::37
EOT
(
if ! "${BUILDDIR}/build/libtool" exec valgrind -v --log-file=valgrind.log --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_QUERY}" -F queries -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
then
exit 1
fi
) 2>&1 > output
if ! awk '/^==.*(definitely|indirectly|possibly) lost/{print;if($4>0)exit(1)}' valgrind.log
then
cat valgrind.log
cat output
exit 1
fi

View File

@ -0,0 +1 @@
. DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5

View File

@ -0,0 +1,16 @@
BaseName: 225-stub-only-valgrind-checks
Version: 1.0
Description: Run valgrind to detect memory leaks
CreationDate: ma mrt 21 16:24:56 CET 2016
Maintainer: Willem Toorop
Category:
Component:
CmdDepends:
Depends: 110-link.tpkg
Help:
Pre:
Post:
Test: 225-stub-only-valgrind-checks.test
AuxFiles:
Passed:
Failure:

View File

@ -0,0 +1,26 @@
# #-- 225-stub-only-valgrind-checks.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
cat >queries <<EOT
NS .
-A getdnsapi.net
qwerlkjhasdfpuiqwyerm.1234kjhrqwersv.com
-G TXT bogus.nlnetlabs.nl
-H 8.8.8.8
-H 2a04:b900:0:100::37
EOT
(
if ! "${BUILDDIR}/build-stub-only/libtool" exec valgrind -v --log-file=valgrind.log --leak-check=full --error-exitcode=1 --track-origins=yes "${GETDNS_STUB_QUERY}" -F queries -f "${TPKG_NAME}.ds" +dnssec_return_validation_chain
then
exit 1
fi
) 2>&1 > output
if ! awk '/^==.*(definitely|indirectly|possibly) lost/{print;if($4>0)exit(1)}' valgrind.log
then
cat valgrind.log
cat output
exit 1
fi

View File

@ -132,6 +132,7 @@ static int my_event_base_dispatch(struct ub_event_base* base)
/* We run the event loop extension for which this ub_event_base is an
* interface ourselfs, so no need to let libunbound call dispatch.
*/
DEBUG_SCHED("UB_LOOP ERROR: my_event_base_dispatch()\n");
return -1;
}
@ -145,20 +146,36 @@ static int my_event_base_loopexit(struct ub_event_base* base, struct timeval* tv
return 0;
}
#define CLEAR_MY_EVENT(ev) \
do { (ev)->loop->extension->vmt->clear((ev)->loop->extension, \
&(ev)->gev); (ev)->added = 0; if ((ev)->active) { \
*(ev)->active = 0; (ev)->active = NULL; }} while(0)
static void clear_my_event(my_event *ev)
{
DEBUG_SCHED("UB_LOOP: to clear %p(%d, %d, %"PRIu64"), total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
(ev)->loop->extension->vmt->clear((ev)->loop->extension, &(ev)->gev);
(ev)->added = 0;
if ((ev)->active) {
*(ev)->active = 0;
(ev)->active = NULL;
}
DEBUG_SCHED("UB_LOOP: %p(%d, %d, %"PRIu64") cleared, total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, --ev->loop->n_events);
}
static getdns_return_t schedule_my_event(my_event *ev)
{
getdns_return_t r;
if (ev->gev.read_cb || ev->gev.write_cb || ev->gev.write_cb) {
DEBUG_SCHED("UB_LOOP: to schedule %p(%d, %d, %"PRIu64"), total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
if (ev->gev.read_cb || ev->gev.write_cb || ev->gev.timeout_cb) {
if ((r = ev->loop->extension->vmt->schedule(
ev->loop->extension, ev->fd, ev->timeout, &ev->gev)))
ev->loop->extension, ev->fd, ev->timeout, &ev->gev))) {
DEBUG_SCHED("UB_LOOP ERROR: scheduling event: %p\n", ev);
return r;
}
ev->added = 1;
DEBUG_SCHED("UB_LOOP: event %p(%d, %d, %"PRIu64") scheduled, "
"total: %d\n", ev, ev->fd, ev->bits, ev->timeout
, ++ev->loop->n_events);
}
return GETDNS_RETURN_GOOD;
}
@ -184,7 +201,7 @@ static void read_cb(void *userarg)
if (active) {
ev->active = NULL;
if ((ev->bits & UB_EV_PERSIST) == 0)
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
}
}
@ -209,7 +226,7 @@ static void write_cb(void *userarg)
if (active) {
ev->active = NULL;
if ((ev->bits & UB_EV_PERSIST) == 0)
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
}
}
@ -224,7 +241,7 @@ static void timeout_cb(void *userarg)
if (active) {
ev->active = NULL;
if ((ev->bits & UB_EV_PERSIST) == 0)
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
}
}
@ -234,7 +251,7 @@ static getdns_return_t set_gev_callbacks(my_event* ev, short bits)
if (ev->bits != bits) {
if (added)
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
ev->gev.read_cb = bits & UB_EV_READ ? read_cb : NULL;
ev->gev.write_cb = bits & UB_EV_WRITE ? write_cb : NULL;
@ -263,7 +280,7 @@ static void my_event_set_fd(struct ub_event* ub_ev, int fd)
if (ev->fd != fd) {
if (ev->added) {
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
ev->fd = fd;
(void) schedule_my_event(ev);
} else
@ -279,7 +296,7 @@ static void my_event_free(struct ub_event* ev)
static int my_event_del(struct ub_event* ev)
{
if (AS_MY_EVENT(ev)->added)
CLEAR_MY_EVENT(AS_MY_EVENT(ev));
clear_my_event(AS_MY_EVENT(ev));
return 0;
}
@ -315,11 +332,13 @@ static int my_timer_add(struct ub_event* ub_ev, struct ub_event_base* base,
{
my_event *ev = AS_MY_EVENT(ub_ev);
if (!base || !cb || !tv || AS_UB_LOOP(base) != ev->loop)
if (!base || !cb || !tv || AS_UB_LOOP(base) != ev->loop) {
DEBUG_SCHED("UB_LOOP ERROR: my_timer_add()\n");
return -1;
}
if (ev->added)
CLEAR_MY_EVENT(ev);
clear_my_event(ev);
ev->cb = cb;
ev->arg = arg;
@ -335,12 +354,14 @@ static int my_timer_del(struct ub_event* ev)
static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv)
{
/* Only unbound daaemon workers use signals */
DEBUG_SCHED("UB_LOOP ERROR: signal_add()\n");
return -1;
}
static int my_signal_del(struct ub_event* ub_ev)
{
/* Only unbound daaemon workers use signals */
DEBUG_SCHED("UB_LOOP ERROR: signal_del()\n");
return -1;
}
@ -439,6 +460,9 @@ void _getdns_ub_loop_init(_getdns_ub_loop *loop, struct mem_funcs *mf, getdns_ev
loop->mf = *mf;
loop->extension = extension;
loop->running = 1;
#if defined(SCHED_DEBUG) && SCHED_DEBUG
loop->n_events = 0;
#endif
}
#endif

View File

@ -40,6 +40,7 @@
#include "getdns/getdns.h"
#include "getdns/getdns_extra.h"
#include "types-internal.h"
#include "debug.h"
#ifdef HAVE_UNBOUND_EVENT_H
#include <unbound-event.h>
@ -61,6 +62,9 @@ typedef struct _getdns_ub_loop {
struct mem_funcs mf;
getdns_eventloop *extension;
int running;
#if defined(SCHED_DEBUG) && SCHED_DEBUG
int n_events;
#endif
} _getdns_ub_loop;
void _getdns_ub_loop_init(_getdns_ub_loop *loop, struct mem_funcs *mf, getdns_eventloop *extension);

View File

@ -329,11 +329,10 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i)
_getdns_list_create_with_mf(mf)))
goto rdata_error;
if (_getdns_list_append_dict(
if (_getdns_list_append_this_dict(
repeat_list, repeat_dict))
goto rdata_error;
getdns_dict_destroy(repeat_dict);
repeat_dict = NULL;
}
if (!(repeat_dict =
@ -364,22 +363,19 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i)
if (!repeat_list && !(repeat_list =
_getdns_list_create_with_mf(mf)))
goto rdata_error;
if (_getdns_list_append_dict(repeat_list, repeat_dict))
if (_getdns_list_append_this_dict(repeat_list, repeat_dict))
goto rdata_error;
getdns_dict_destroy(repeat_dict);
repeat_dict = NULL;
}
if (repeat_list) {
if (getdns_dict_set_list(rdata_dict,
if (_getdns_dict_set_this_list(rdata_dict,
rdf_storage.rdd_repeat->name, repeat_list))
goto rdata_error;
getdns_list_destroy(repeat_list);
repeat_list = NULL;
}
if (getdns_dict_set_dict(rr_dict, "rdata", rdata_dict))
if (_getdns_dict_set_this_dict(rr_dict, "rdata", rdata_dict))
goto rdata_error;
getdns_dict_destroy(rdata_dict);
return rr_dict;
rdata_error:
@ -529,8 +525,9 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req,
SET_WIRE_CNT(arcount, ARCOUNT);
/* header */
if ((r = getdns_dict_set_dict(result, "header", header)))
if ((r = _getdns_dict_set_this_dict(result, "header", header)))
goto error;
header = NULL;
canonical_name = req->owner->name;
canonical_name_len = req->owner->name_len;
@ -548,14 +545,14 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req,
section = _getdns_rr_iter_section(rr_iter);
if (section == GLDNS_SECTION_QUESTION) {
if (getdns_dict_set_dict(result, "question", rr_dict))
if (_getdns_dict_set_this_dict(result, "question", rr_dict))
goto error;
else rr_dict = NULL;
continue;
}
if (_getdns_list_append_dict(sections[section], rr_dict))
if (_getdns_list_append_this_dict(sections[section], rr_dict))
goto error;
else rr_dict = NULL;
rr_type = gldns_read_uint16(rr_iter->rr_type);
if (section > GLDNS_SECTION_QUESTION &&
@ -589,6 +586,9 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req,
&rdf_iter_storage, rr_iter)))
continue;
if (!just_addrs)
continue;
bin_size = rdf_iter->nxt - rdf_iter->pos;
bin_data = rdf_iter->pos;
if (!set_dict(&rr_dict, getdns_dict_create_with_context(context)) ||
@ -599,22 +599,26 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req,
_getdns_dict_set_const_bindata(
rr_dict, "address_data", bin_size, bin_data) ||
(just_addrs && _getdns_list_append_dict(just_addrs, rr_dict))) {
_getdns_list_append_this_dict(just_addrs, rr_dict)) {
goto error;
}
rr_dict = NULL;
}
if (getdns_dict_set_list(result, "answer",
sections[GLDNS_SECTION_ANSWER]) ||
if (!_getdns_dict_set_this_list(result, "answer",
sections[GLDNS_SECTION_ANSWER]))
sections[GLDNS_SECTION_ANSWER] = NULL;
else goto error;
getdns_dict_set_list(result, "authority",
sections[GLDNS_SECTION_AUTHORITY]) ||
if (!_getdns_dict_set_this_list(result, "authority",
sections[GLDNS_SECTION_AUTHORITY]))
sections[GLDNS_SECTION_AUTHORITY] = NULL;
else goto error;
getdns_dict_set_list(result, "additional",
sections[GLDNS_SECTION_ADDITIONAL])) {
goto error;
}
if (!_getdns_dict_set_this_list(result, "additional",
sections[GLDNS_SECTION_ADDITIONAL]))
sections[GLDNS_SECTION_ADDITIONAL] = NULL;
else goto error;
/* other stuff
* Note that spec doesn't explicitely mention these.
@ -731,8 +735,9 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req,
_getdns_list_append_int(bad_dns, GETDNS_BAD_DNS_ALL_NUMERIC_LABEL))
goto error;
if (getdns_dict_set_list(result, "bad_dns", bad_dns))
if (_getdns_dict_set_this_list(result, "bad_dns", bad_dns))
goto error;
else bad_dns = NULL;
goto success;
error:
@ -788,7 +793,7 @@ _getdns_create_call_reporting_dict(
_getdns_sockaddr_to_dict(
context, &netreq->upstream->addr, &address_debug);
if (getdns_dict_set_dict(netreq_debug, "query_to", address_debug)) {
if (_getdns_dict_set_this_dict(netreq_debug,"query_to",address_debug)){
getdns_dict_destroy(address_debug);
return NULL;
}
@ -802,8 +807,6 @@ _getdns_create_call_reporting_dict(
getdns_dict_destroy(netreq_debug);
return NULL;
}
getdns_dict_destroy(address_debug);
if (transport != GETDNS_TRANSPORT_UDP) {
/* Report the idle timeout actually used on the connection. Must trim,
maximum used in practice is 6553500ms, but this is stored in a uint64_t.*/
@ -848,7 +851,6 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
getdns_dict *reply;
getdns_bindata *canonical_name = NULL;
int nreplies = 0, nanswers = 0, nsecure = 0, ninsecure = 0, nbogus = 0;
getdns_bindata full_data;
getdns_dict *netreq_debug;
/* info (bools) about dns_req */
@ -950,7 +952,7 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
netreq->tsig_status))
goto error;
}
if (_getdns_list_append_dict(replies_tree, reply)) {
if (_getdns_list_append_this_dict(replies_tree, reply)) {
getdns_dict_destroy(reply);
goto error;
}
@ -960,40 +962,38 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
_getdns_create_call_reporting_dict(context,netreq)))
goto error;
if (_getdns_list_append_dict(
if (_getdns_list_append_this_dict(
call_reporting, netreq_debug)) {
getdns_dict_destroy(netreq_debug);
goto error;
}
getdns_dict_destroy(netreq_debug);
}
getdns_dict_destroy(reply);
/* buffer */
full_data.data = netreq->response;
full_data.size = netreq->response_len;
if (_getdns_list_append_bindata(replies_full, &full_data))
if (_getdns_list_append_const_bindata(replies_full,
netreq->response_len, netreq->response))
goto error;
}
if (getdns_dict_set_list(result, "replies_tree", replies_tree))
if (_getdns_dict_set_this_list(result, "replies_tree", replies_tree))
goto error;
getdns_list_destroy(replies_tree);
replies_tree = NULL;
if (call_reporting &&
getdns_dict_set_list(result, "call_reporting", call_reporting))
goto error_free_call_reporting;
if (getdns_dict_set_list(result, "replies_full", replies_full))
if (call_reporting) {
if (_getdns_dict_set_this_list(
result, "call_reporting", call_reporting))
goto error_free_call_reporting;
call_reporting = NULL;
}
if (_getdns_dict_set_this_list(result, "replies_full", replies_full))
goto error_free_replies_full;
getdns_list_destroy(replies_full);
if (just_addrs && getdns_dict_set_list(
result, GETDNS_STR_KEY_JUST_ADDRS, just_addrs))
goto error_free_result;
getdns_list_destroy(just_addrs);
replies_full = NULL;
if (just_addrs) {
if (_getdns_dict_set_this_list(
result, GETDNS_STR_KEY_JUST_ADDRS, just_addrs))
goto error_free_result;
just_addrs = NULL;
}
if (getdns_dict_set_int(result, GETDNS_STR_KEY_STATUS,
nreplies == 0 ? GETDNS_RESPSTATUS_ALL_TIMEOUT :
completed_request->dnssec_return_only_secure && nsecure == 0 && ninsecure > 0
@ -1291,8 +1291,8 @@ void _getdns_wire2list(uint8_t *pkt, size_t pkt_len, getdns_list *l)
if (!(rr_dict = _getdns_rr_iter2rr_dict(&l->mf, rr)))
continue;
(void)_getdns_list_append_dict(l, rr_dict);
getdns_dict_destroy(rr_dict);
if (_getdns_list_append_this_dict(l, rr_dict))
getdns_dict_destroy(rr_dict);
}
}

View File

@ -71,12 +71,12 @@ getdns_return_t getdns_apply_network_result(getdns_network_req* netreq,
* @return GETDNS_RETURN_GOOD on success
* @return GETDNS_RETURN_GENERAL_ERROR if out of memory
*/
getdns_return_t _getdns_list_append_this_dict(getdns_list *list,
getdns_dict *child_dict);
getdns_return_t _getdns_list_append_dict(getdns_list *list,
const getdns_dict *child_dict);
getdns_return_t _getdns_list_append_list(getdns_list *list,
const getdns_list *child_list);
getdns_return_t _getdns_list_append_bindata(getdns_list *list,
const getdns_bindata *child_bindata);
getdns_return_t _getdns_list_append_string(getdns_list *list,
const char *value);
@ -86,6 +86,12 @@ getdns_return_t _getdns_list_append_int(getdns_list *list,
getdns_return_t _getdns_list_append_const_bindata(getdns_list *list,
size_t size, const void *data);
getdns_return_t _getdns_dict_set_this_dict(getdns_dict *dict,
const char *name, getdns_dict *child_dict);
getdns_return_t _getdns_dict_set_this_list(getdns_dict *dict,
const char *name, getdns_list *child_list);
getdns_return_t _getdns_dict_set_const_bindata(getdns_dict *dict,
const char *name, size_t size, const void *data);