Update check_getdns - build one per event loop abstraction

This commit is contained in:
Neel Goyal 2014-02-21 15:42:06 -05:00
parent 2594d3d575
commit 91daf87f4b
11 changed files with 234 additions and 150 deletions

25
configure vendored
View File

@ -636,12 +636,15 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
TRUST_ANCHOR_FILE
EXTENSION_LDFLAGS
CHECK_EV_PROG
EXTENSION_LIBEV_EXT_LIBS
EXTENSION_LIBEV_LIB
have_libev
CHECK_UV_PROG
EXTENSION_LIBUV_EXT_LIBS
EXTENSION_LIBUV_LIB
have_libuv
CHECK_EVENT_PROG
EXTENSION_LIBEVENT_EXT_LIBS
EXTENSION_LIBEVENT_LIB
have_libevent
@ -11173,6 +11176,7 @@ EXTENSION_LDFLAGS=$LDFLAGS
have_libevent=1
EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"
EXTENSION_LIBEVENT_EXT_LIBS=""
CHECK_EVENT_PROG=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5
$as_echo_n "checking for library containing event_loop... " >&6; }
if ${ac_cv_search_event_loop+:} false; then :
@ -11238,9 +11242,6 @@ _ACEOF
fi
done
$as_echo "#define HAVE_LIBEVENT 1" >>confdefs.h
for ac_header in event2/event.h
do :
ac_fn_c_check_header_compile "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default
@ -11255,6 +11256,7 @@ fi
done
EXTENSION_LIBEVENT_EXT_LIBS="-l$ac_lib"
CHECK_EVENT_PROG=check_getdns_event
else
have_libevent=0
EXTENSION_LIBEVENT_LIB=""
@ -11265,10 +11267,12 @@ fi
# libuv extension
have_libuv=1
EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
EXTENSION_LIBUV_EXT_LIBS=""
CHECK_UV_PROG=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uv_run" >&5
$as_echo_n "checking for library containing uv_run... " >&6; }
if ${ac_cv_search_uv_run+:} false; then :
@ -11322,10 +11326,8 @@ $as_echo "$ac_cv_search_uv_run" >&6; }
ac_res=$ac_cv_search_uv_run
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
$as_echo "#define HAVE_LIBUV 1" >>confdefs.h
EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"
EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"
CHECK_UV_PROG=check_getdns_uv
else
have_libuv=0
EXTENSION_LIBUV_LIB=""
@ -11336,10 +11338,12 @@ fi
# libev extension
have_libev=1
EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"
EXTENSION_LIBEV_EXT_LIBS=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ev_run" >&5
$as_echo_n "checking for library containing ev_run... " >&6; }
if ${ac_cv_search_ev_run+:} false; then :
@ -11393,10 +11397,8 @@ $as_echo "$ac_cv_search_ev_run" >&6; }
ac_res=$ac_cv_search_ev_run
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
$as_echo "#define HAVE_LIBEV 1" >>confdefs.h
EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"
EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"
CHECK_EV_PROG=check_getdns_ev
else
have_libev=0
EXTENSION_LIBEV_LIB=""
@ -11409,6 +11411,7 @@ fi
LIBS=$getdns_LIBS
LDFLAGS=$getdns_LDFLAGS

View File

@ -199,48 +199,54 @@ EXTENSION_LDFLAGS=$LDFLAGS
have_libevent=1
EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"
EXTENSION_LIBEVENT_EXT_LIBS=""
CHECK_EVENT_PROG=""
AC_SEARCH_LIBS([event_loop],
[event_core event],
[AC_CHECK_FUNCS([event_base_new event_base_free])]
[AC_DEFINE([HAVE_LIBEVENT], [1], [Define to 1 to enable the libevent extension])]
[AC_CHECK_HEADERS([event2/event.h],,, [AC_INCLUDES_DEFAULT])]
[EXTENSION_LIBEVENT_EXT_LIBS="-l$ac_lib"],
[EXTENSION_LIBEVENT_EXT_LIBS="-l$ac_lib"]
[CHECK_EVENT_PROG=check_getdns_event],
[have_libevent=0]
[EXTENSION_LIBEVENT_LIB=""])
AC_SUBST(have_libevent)
AC_SUBST(EXTENSION_LIBEVENT_LIB)
AC_SUBST(EXTENSION_LIBEVENT_EXT_LIBS)
AC_SUBST(CHECK_EVENT_PROG)
# libuv extension
have_libuv=1
EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
EXTENSION_LIBUV_EXT_LIBS=""
CHECK_UV_PROG=""
AC_SEARCH_LIBS([uv_run],
[uv],
[AC_DEFINE([HAVE_LIBUV], [1], [Define to 1 to enable the libuv extension])]
[EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"],
[EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"]
[CHECK_UV_PROG=check_getdns_uv],
[have_libuv=0]
[EXTENSION_LIBUV_LIB=""])
AC_SUBST(have_libuv)
AC_SUBST(EXTENSION_LIBUV_LIB)
AC_SUBST(EXTENSION_LIBUV_EXT_LIBS)
AC_SUBST(CHECK_UV_PROG)
# libev extension
have_libev=1
EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"
EXTENSION_LIBEV_EXT_LIBS=""
AC_SEARCH_LIBS([ev_run],
[ev],
[AC_DEFINE([HAVE_LIBEV], [1], [Define to 1 to enable the libev extension])]
[EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"],
[EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"]
[CHECK_EV_PROG=check_getdns_ev],
[have_libev=0]
[EXTENSION_LIBEV_LIB=""])
AC_SUBST(have_libev)
AC_SUBST(EXTENSION_LIBEV_LIB)
AC_SUBST(EXTENSION_LIBEV_EXT_LIBS)
AC_SUBST(CHECK_EV_PROG)
AC_SUBST(EXTENSION_LDFLAGS)

View File

@ -15,12 +15,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 to enable the libev extension */
#undef HAVE_LIBEV
/* Define to 1 to enable the libevent extension */
#undef HAVE_LIBEVENT
/* Define to 1 if you have the `idn' library (-lidn). */
#undef HAVE_LIBIDN
@ -30,9 +24,6 @@
/* Define to 1 if you have the `unbound' library (-lunbound). */
#undef HAVE_LIBUNBOUND
/* Define to 1 to enable the libuv extension */
#undef HAVE_LIBUV
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

View File

@ -39,11 +39,23 @@ LIBTOOL = @libtool@
srcdir = @srcdir@
VPATH = @srcdir@
have_libevent = @have_libevent@
have_libuv = @have_libuv@
have_libev = @have_libev@
EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@
EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@
EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@
CHECK_UV_PROG=@CHECK_UV_PROG@
CHECK_EVENT_PROG=@CHECK_EVENT_PROG@
CHECK_EV_PROG=@CHECK_EV_PROG@
CC=@CC@
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99 $(cflags)
LDFLAGS=@LDFLAGS@ -L. -L.. -L$(srcdir)/../ -L/usr/local/lib
LDLIBS=-lgetdns @LIBS@ -lcheck
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync check_getdns tests_dnssec
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync check_getdns tests_dnssec $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG)
.SUFFIXES: .c .o .a .lo .h
@ -69,8 +81,17 @@ tests_stub_sync: tests_stub_sync.o
check_getdns_common: check_getdns_common.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.o
check_getdns: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o
check_getdns: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_selectloop.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_selectloop.o
check_getdns_event: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libevent.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(EXTENSION_LIBEVENT_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libevent.o
check_getdns_uv: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libuv.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_uv $(EXTENSION_LIBUV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libuv.o
check_getdns_ev: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libev.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_ev $(EXTENSION_LIBEV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libev.o
tests_dnssec: tests_dnssec.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
@ -78,6 +99,9 @@ tests_dnssec: tests_dnssec.o testmessages.o
test: all
./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
@echo "All tests OK"
clean:

View File

@ -32,29 +32,11 @@
#include <check.h>
#include <getdns/getdns.h>
#include "config.h"
#include <dlfcn.h>
#if HAVE_LIBEVENT
#include "check_getdns_libevent.h"
typedef getdns_return_t
(*getdns_extension_set_libevent_loop_fn)(struct getdns_context *context,
struct event_base *this_event_base);
#endif
#if HAVE_LIBUV
#include <uv.h>
#endif
#if HAVE_LIBEV
#include "check_getdns_libev.h"
#endif
#include "check_getdns_common.h"
#include "check_getdns_eventloop.h"
#include <unistd.h>
#include <sys/time.h>
#ifdef __APPLE__
#define SO_EXT ".dylib"
#else
#define SO_EXT ".so"
#endif
int callback_called = 0;
int callback_completed = 0;
int callback_canceled = 0;
@ -335,94 +317,10 @@ void update_callbackfn(struct getdns_context *context,
changed_item, expected_changed_item);
}
#define NO_LOOP 0
#define LIBEVENT_LOOP 1
#define LIBUV_LOOP 2
#define LIBEV_LOOP 3
static int get_event_loop_type() {
int result = 0;
char* loop = getenv("GETDNS_EVLOOP");
if (loop && strcmp("libevent", loop) == 0) {
result = LIBEVENT_LOOP;
}
if (loop && strcmp("libuv", loop) == 0) {
result = LIBUV_LOOP;
}
if (loop && strcmp("libev", loop) == 0) {
result = LIBEV_LOOP;
}
return result;
}
void run_event_loop(struct getdns_context* context, void* eventloop) {
int event_loop_type = get_event_loop_type();
if (event_loop_type == NO_LOOP) {
struct timeval tv;
while (getdns_context_get_num_pending_requests(context, &tv) > 0) {
int fd = getdns_context_fd(context);
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(fd, &read_fds);
select(fd + 1, &read_fds, NULL, NULL, &tv);
getdns_context_process_async(context);
}
}
// #if HAVE_LIBEVENT
// else if (event_loop_type == LIBEVENT_LOOP) {
// struct event_base* base = (struct event_base*) eventloop;
// while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
// event_base_loop(base, EVLOOP_ONCE);
// }
// }
// #endif
// #if HAVE_LIBUV
// else if (event_loop_type == LIBUV_LOOP) {
// uv_loop_t* loop = (uv_loop_t*) eventloop;
// while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
// uv_run(loop, UV_RUN_ONCE);
// }
// }
// #endif
// #if HAVE_LIBEV
// else if (event_loop_type == LIBEV_LOOP) {
// run_libev_event_loop(context, eventloop);
// }
// #endif
run_event_loop_impl(context, eventloop);
}
void* create_event_base(struct getdns_context* context) {
// int event_loop_type = get_event_loop_type();
// #if HAVE_LIBEVENT
// if (event_loop_type == LIBEVENT_LOOP) {
// /* load the lib */
// void* ext_library = dlopen("libgetdns_ext_event" SO_EXT, RTLD_LAZY);
// if (!ext_library) { return NULL; }
// void* ext_setter = dlsym(ext_library,"getdns_extension_set_libevent_base");
// if (!ext_setter) { return NULL; }
// getdns_extension_set_libevent_loop_fn fn = (getdns_extension_set_libevent_loop_fn) ext_setter;
// struct event_base* result = event_base_new();
// ck_assert_msg(result != NULL, "Event base creation failed");
// ASSERT_RC(fn(context, result),
// GETDNS_RETURN_GOOD,
// "Return code from getdns_extension_set_libevent_base()");
// return result;
// }
//#endif
// #if HAVE_LIBUV
// if (event_loop_type == LIBUV_LOOP) {
// uv_loop_t* result = uv_default_loop();
// ck_assert_msg(result != NULL, "UV loop creation failed");
// ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
// GETDNS_RETURN_GOOD,
// "Return code from getdns_extension_set_libuv_loop()");
// return result;
// }
// #endif
// #if HAVE_LIBEV
// if (event_loop_type == LIBEV_LOOP) {
// return create_libev_base(context);
// }
// #endif
return NULL;
return create_eventloop_impl(context);
}

View File

@ -64,9 +64,9 @@
{ \
size_t buflen = MAXLEN; \
char error_string[MAXLEN]; \
getdns_return_t evaluated_rc = rc; \
uint32_t evaluated_rc = rc; \
getdns_strerror(evaluated_rc, error_string, buflen); \
ck_assert_msg(evaluated_rc == expected_rc, \
ck_assert_msg((uint32_t) evaluated_rc == (uint32_t) expected_rc, \
"%s: expecting %s: %d, but received: %d: %s", \
prefix, #expected_rc, expected_rc, evaluated_rc, error_string); \
}

View File

@ -34,15 +34,13 @@
*/
/* this is used to prevent header conflicts with libevent and libev */
#ifndef _check_getdns_libev_h_
#define _check_getdns_libev_h_
#ifndef _check_getdns_eventloop_h_
#define _check_getdns_eventloop_h_
#include "config.h"
#if HAVE_LIBEV
struct getdns_context* context;
void run_libev_event_loop(struct getdns_context* context, void* eventloop);
void* create_libev_base(struct getdns_context* context);
#endif
void run_event_loop_impl(struct getdns_context* context, void* eventloop);
void* create_eventloop_impl(struct getdns_context* context);
#endif

View File

@ -33,24 +33,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "check_getdns_libev.h"
#if HAVE_LIBEV
#include "check_getdns_eventloop.h"
#include <getdns/getdns_ext_libev.h>
#include <ev.h>
#include <check.h>
#include "check_getdns_common.h"
void run_libev_event_loop(struct getdns_context* context, void* eventloop) {
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
struct ev_loop* loop = (struct ev_loop*) eventloop;
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
ev_run(loop, EVRUN_ONCE);
}
}
void* create_libev_base(struct getdns_context* context) {
void* create_eventloop_impl(struct getdns_context* context) {
struct ev_loop* result = ev_default_loop(0);
ck_assert_msg(result != NULL, "EV loop creation failed");
ASSERT_RC(getdns_extension_set_libev_loop(context, result),
@ -58,5 +55,3 @@ void* create_libev_base(struct getdns_context* context) {
"Return code from getdns_extension_set_libev_loop()");
return result;
}
#endif

View File

@ -0,0 +1,57 @@
/**
* \file
* \brief Public interfaces to getdns, include in your application to use getdns API.
*
* This source was taken from the original pseudo-implementation by
* Paul Hoffman.
*/
/*
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "check_getdns_eventloop.h"
#include <getdns/getdns_ext_libevent.h>
#include "check_getdns_libevent.h"
#include <check.h>
#include "check_getdns_common.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
struct event_base* base = (struct event_base*) eventloop;
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
event_base_loop(base, EVLOOP_ONCE);
}
}
void* create_eventloop_impl(struct getdns_context* context) {
struct event_base* result = event_base_new();
ck_assert_msg(result != NULL, "Event base creation failed");
ASSERT_RC(getdns_extension_set_libevent_base(context, result),
GETDNS_RETURN_GOOD,
"Return code from getdns_extension_set_libevent_base()");
return result;
}

View File

@ -0,0 +1,58 @@
/**
* \file
* \brief Public interfaces to getdns, include in your application to use getdns API.
*
* This source was taken from the original pseudo-implementation by
* Paul Hoffman.
*/
/*
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "check_getdns_eventloop.h"
#include <getdns/getdns_ext_libuv.h>
#include <uv.h>
#include <check.h>
#include "check_getdns_common.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
uv_loop_t* loop = (uv_loop_t*) eventloop;
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
uv_run(loop, UV_RUN_ONCE);
}
}
void* create_eventloop_impl(struct getdns_context* context) {
uv_loop_t* result = uv_default_loop();
ck_assert_msg(result != NULL, "UV loop creation failed");
ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
GETDNS_RETURN_GOOD,
"Return code from getdns_extension_set_libuv_loop()");
return result;
}

View File

@ -0,0 +1,54 @@
/**
* \file
* \brief Public interfaces to getdns, include in your application to use getdns API.
*
* This source was taken from the original pseudo-implementation by
* Paul Hoffman.
*/
/*
* Copyright (c) 2013, NLNet Labs, Versign, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "check_getdns_eventloop.h"
#include <getdns/getdns_extra.h>
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
struct timeval tv;
while (getdns_context_get_num_pending_requests(context, &tv) > 0) {
int fd = getdns_context_fd(context);
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(fd, &read_fds);
select(fd + 1, &read_fds, NULL, NULL, &tv);
getdns_context_process_async(context);
}
}
void* create_eventloop_impl(struct getdns_context* context) {
return NULL;
}