Modify check getdns to only use default loop. Adding changes for extensions in next commit

This commit is contained in:
Neel Goyal 2014-02-21 14:08:37 -05:00
parent 2f0bcd665b
commit 2594d3d575
6 changed files with 100 additions and 8672 deletions

8619
aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

13
configure vendored
View File

@ -11238,6 +11238,9 @@ _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
@ -11319,7 +11322,10 @@ $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"
EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"
$as_echo "#define HAVE_LIBUV 1" >>confdefs.h
EXTENSION_LIBUV_EXT_LIBS="-l$ac_lib"
else
have_libuv=0
EXTENSION_LIBUV_LIB=""
@ -11387,7 +11393,10 @@ $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"
EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"
$as_echo "#define HAVE_LIBEV 1" >>confdefs.h
EXTENSION_LIBEV_EXT_LIBS="-l$ac_lib"
else
have_libev=0
EXTENSION_LIBEV_LIB=""

View File

@ -202,6 +202,7 @@ EXTENSION_LIBEVENT_EXT_LIBS=""
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"],
[have_libevent=0]
@ -217,6 +218,7 @@ EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
EXTENSION_LIBUV_EXT_LIBS=""
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"],
[have_libuv=0]
[EXTENSION_LIBUV_LIB=""])
@ -231,6 +233,7 @@ 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"],
[have_libev=0]
[EXTENSION_LIBEV_LIB=""])

View File

@ -15,6 +15,12 @@
/* 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
@ -24,6 +30,9 @@
/* 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

@ -61,7 +61,7 @@ tests_list: tests_list.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.o testmessages.o
tests_stub_async: tests_stub_async.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(LDLIBS) -o $@ tests_stub_async.o testmessages.o
tests_stub_sync: tests_stub_sync.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.o
@ -69,11 +69,11 @@ 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_libev.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_libev.o check_getdns_context_set_timeout.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
tests_dnssec: tests_dnssec.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
test: all

View File

@ -32,12 +32,14 @@
#include <check.h>
#include <getdns/getdns.h>
#include "config.h"
#include <dlfcn.h>
#if HAVE_LIBEVENT
#include "check_getdns_libevent.h"
#include <getdns/getdns_ext_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 <getdns/getdns_ext_libuv.h>
#include <uv.h>
#endif
#if HAVE_LIBEV
@ -47,6 +49,12 @@
#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,21 +343,15 @@ void update_callbackfn(struct getdns_context *context,
static int get_event_loop_type() {
int result = 0;
char* loop = getenv("GETDNS_EVLOOP");
#if HAVE_LIBEVENT
if (loop && strcmp("libevent", loop) == 0) {
result = LIBEVENT_LOOP;
}
#endif
#if HAVE_LIBUV
if (loop && strcmp("uv", loop) == 0) {
if (loop && strcmp("libuv", loop) == 0) {
result = LIBUV_LOOP;
}
#endif
#if HAVE_LIBEV
if (loop && strcmp("libev", loop) == 0) {
result = LIBEV_LOOP;
}
#endif
return result;
}
@ -366,55 +368,61 @@ void run_event_loop(struct getdns_context* context, void* eventloop) {
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
// #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
}
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) {
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;
}
#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
// 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;
}