mirror of https://github.com/getdnsapi/getdns.git
Modify check getdns to only use default loop. Adding changes for extensions in next commit
This commit is contained in:
parent
2f0bcd665b
commit
2594d3d575
File diff suppressed because it is too large
Load Diff
|
@ -11238,6 +11238,9 @@ _ACEOF
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_LIBEVENT 1" >>confdefs.h
|
||||||
|
|
||||||
for ac_header in event2/event.h
|
for ac_header in event2/event.h
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_header_compile "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default
|
ac_fn_c_check_header_compile "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default
|
||||||
|
@ -11319,6 +11322,9 @@ $as_echo "$ac_cv_search_uv_run" >&6; }
|
||||||
ac_res=$ac_cv_search_uv_run
|
ac_res=$ac_cv_search_uv_run
|
||||||
if test "$ac_res" != no; then :
|
if test "$ac_res" != no; then :
|
||||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
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"
|
||||||
else
|
else
|
||||||
have_libuv=0
|
have_libuv=0
|
||||||
|
@ -11387,6 +11393,9 @@ $as_echo "$ac_cv_search_ev_run" >&6; }
|
||||||
ac_res=$ac_cv_search_ev_run
|
ac_res=$ac_cv_search_ev_run
|
||||||
if test "$ac_res" != no; then :
|
if test "$ac_res" != no; then :
|
||||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
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"
|
||||||
else
|
else
|
||||||
have_libev=0
|
have_libev=0
|
||||||
|
|
|
@ -202,6 +202,7 @@ EXTENSION_LIBEVENT_EXT_LIBS=""
|
||||||
AC_SEARCH_LIBS([event_loop],
|
AC_SEARCH_LIBS([event_loop],
|
||||||
[event_core event],
|
[event_core event],
|
||||||
[AC_CHECK_FUNCS([event_base_new event_base_free])]
|
[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])]
|
[AC_CHECK_HEADERS([event2/event.h],,, [AC_INCLUDES_DEFAULT])]
|
||||||
[EXTENSION_LIBEVENT_EXT_LIBS="-l$ac_lib"],
|
[EXTENSION_LIBEVENT_EXT_LIBS="-l$ac_lib"],
|
||||||
[have_libevent=0]
|
[have_libevent=0]
|
||||||
|
@ -217,6 +218,7 @@ EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
|
||||||
EXTENSION_LIBUV_EXT_LIBS=""
|
EXTENSION_LIBUV_EXT_LIBS=""
|
||||||
AC_SEARCH_LIBS([uv_run],
|
AC_SEARCH_LIBS([uv_run],
|
||||||
[uv],
|
[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"],
|
||||||
[have_libuv=0]
|
[have_libuv=0]
|
||||||
[EXTENSION_LIBUV_LIB=""])
|
[EXTENSION_LIBUV_LIB=""])
|
||||||
|
@ -231,6 +233,7 @@ EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"
|
||||||
EXTENSION_LIBEV_EXT_LIBS=""
|
EXTENSION_LIBEV_EXT_LIBS=""
|
||||||
AC_SEARCH_LIBS([ev_run],
|
AC_SEARCH_LIBS([ev_run],
|
||||||
[ev],
|
[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"],
|
||||||
[have_libev=0]
|
[have_libev=0]
|
||||||
[EXTENSION_LIBEV_LIB=""])
|
[EXTENSION_LIBEV_LIB=""])
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#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). */
|
/* Define to 1 if you have the `idn' library (-lidn). */
|
||||||
#undef HAVE_LIBIDN
|
#undef HAVE_LIBIDN
|
||||||
|
|
||||||
|
@ -24,6 +30,9 @@
|
||||||
/* Define to 1 if you have the `unbound' library (-lunbound). */
|
/* Define to 1 if you have the `unbound' library (-lunbound). */
|
||||||
#undef HAVE_LIBUNBOUND
|
#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. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
|
|
@ -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
|
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.o testmessages.o
|
||||||
|
|
||||||
tests_stub_async: tests_stub_async.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
|
tests_stub_sync: tests_stub_sync.o
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ 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
|
check_getdns_common: check_getdns_common.o
|
||||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ 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
|
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_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_context_set_timeout.o
|
||||||
|
|
||||||
tests_dnssec: tests_dnssec.o testmessages.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
|
test: all
|
||||||
|
|
|
@ -32,12 +32,14 @@
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <getdns/getdns.h>
|
#include <getdns/getdns.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <dlfcn.h>
|
||||||
#if HAVE_LIBEVENT
|
#if HAVE_LIBEVENT
|
||||||
#include "check_getdns_libevent.h"
|
#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
|
#endif
|
||||||
#if HAVE_LIBUV
|
#if HAVE_LIBUV
|
||||||
#include <getdns/getdns_ext_libuv.h>
|
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LIBEV
|
#if HAVE_LIBEV
|
||||||
|
@ -47,6 +49,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define SO_EXT ".dylib"
|
||||||
|
#else
|
||||||
|
#define SO_EXT ".so"
|
||||||
|
#endif
|
||||||
|
|
||||||
int callback_called = 0;
|
int callback_called = 0;
|
||||||
int callback_completed = 0;
|
int callback_completed = 0;
|
||||||
int callback_canceled = 0;
|
int callback_canceled = 0;
|
||||||
|
@ -335,21 +343,15 @@ void update_callbackfn(struct getdns_context *context,
|
||||||
static int get_event_loop_type() {
|
static int get_event_loop_type() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
char* loop = getenv("GETDNS_EVLOOP");
|
char* loop = getenv("GETDNS_EVLOOP");
|
||||||
#if HAVE_LIBEVENT
|
|
||||||
if (loop && strcmp("libevent", loop) == 0) {
|
if (loop && strcmp("libevent", loop) == 0) {
|
||||||
result = LIBEVENT_LOOP;
|
result = LIBEVENT_LOOP;
|
||||||
}
|
}
|
||||||
#endif
|
if (loop && strcmp("libuv", loop) == 0) {
|
||||||
#if HAVE_LIBUV
|
|
||||||
if (loop && strcmp("uv", loop) == 0) {
|
|
||||||
result = LIBUV_LOOP;
|
result = LIBUV_LOOP;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if HAVE_LIBEV
|
|
||||||
if (loop && strcmp("libev", loop) == 0) {
|
if (loop && strcmp("libev", loop) == 0) {
|
||||||
result = LIBEV_LOOP;
|
result = LIBEV_LOOP;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,55 +368,61 @@ void run_event_loop(struct getdns_context* context, void* eventloop) {
|
||||||
getdns_context_process_async(context);
|
getdns_context_process_async(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if HAVE_LIBEVENT
|
// #if HAVE_LIBEVENT
|
||||||
else if (event_loop_type == LIBEVENT_LOOP) {
|
// else if (event_loop_type == LIBEVENT_LOOP) {
|
||||||
struct event_base* base = (struct event_base*) eventloop;
|
// struct event_base* base = (struct event_base*) eventloop;
|
||||||
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
// while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||||
event_base_loop(base, EVLOOP_ONCE);
|
// event_base_loop(base, EVLOOP_ONCE);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
#if HAVE_LIBUV
|
// #if HAVE_LIBUV
|
||||||
else if (event_loop_type == LIBUV_LOOP) {
|
// else if (event_loop_type == LIBUV_LOOP) {
|
||||||
uv_loop_t* loop = (uv_loop_t*) eventloop;
|
// uv_loop_t* loop = (uv_loop_t*) eventloop;
|
||||||
while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
// while (getdns_context_get_num_pending_requests(context, NULL) > 0) {
|
||||||
uv_run(loop, UV_RUN_ONCE);
|
// uv_run(loop, UV_RUN_ONCE);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
#if HAVE_LIBEV
|
// #if HAVE_LIBEV
|
||||||
else if (event_loop_type == LIBEV_LOOP) {
|
// else if (event_loop_type == LIBEV_LOOP) {
|
||||||
run_libev_event_loop(context, eventloop);
|
// run_libev_event_loop(context, eventloop);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void* create_event_base(struct getdns_context* context) {
|
void* create_event_base(struct getdns_context* context) {
|
||||||
int event_loop_type = get_event_loop_type();
|
// int event_loop_type = get_event_loop_type();
|
||||||
#if HAVE_LIBEVENT
|
// #if HAVE_LIBEVENT
|
||||||
if (event_loop_type == LIBEVENT_LOOP) {
|
// if (event_loop_type == LIBEVENT_LOOP) {
|
||||||
struct event_base* result = event_base_new();
|
// /* load the lib */
|
||||||
ck_assert_msg(result != NULL, "Event base creation failed");
|
// void* ext_library = dlopen("libgetdns_ext_event" SO_EXT, RTLD_LAZY);
|
||||||
ASSERT_RC(getdns_extension_set_libevent_base(context, result),
|
// if (!ext_library) { return NULL; }
|
||||||
GETDNS_RETURN_GOOD,
|
// void* ext_setter = dlsym(ext_library,"getdns_extension_set_libevent_base");
|
||||||
"Return code from getdns_extension_set_libevent_base()");
|
// if (!ext_setter) { return NULL; }
|
||||||
return result;
|
// getdns_extension_set_libevent_loop_fn fn = (getdns_extension_set_libevent_loop_fn) ext_setter;
|
||||||
}
|
// struct event_base* result = event_base_new();
|
||||||
#endif
|
// ck_assert_msg(result != NULL, "Event base creation failed");
|
||||||
#if HAVE_LIBUV
|
// ASSERT_RC(fn(context, result),
|
||||||
if (event_loop_type == LIBUV_LOOP) {
|
// GETDNS_RETURN_GOOD,
|
||||||
uv_loop_t* result = uv_default_loop();
|
// "Return code from getdns_extension_set_libevent_base()");
|
||||||
ck_assert_msg(result != NULL, "UV loop creation failed");
|
// return result;
|
||||||
ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
|
// }
|
||||||
GETDNS_RETURN_GOOD,
|
//#endif
|
||||||
"Return code from getdns_extension_set_libuv_loop()");
|
// #if HAVE_LIBUV
|
||||||
return result;
|
// if (event_loop_type == LIBUV_LOOP) {
|
||||||
}
|
// uv_loop_t* result = uv_default_loop();
|
||||||
#endif
|
// ck_assert_msg(result != NULL, "UV loop creation failed");
|
||||||
#if HAVE_LIBEV
|
// ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
|
||||||
if (event_loop_type == LIBEV_LOOP) {
|
// GETDNS_RETURN_GOOD,
|
||||||
return create_libev_base(context);
|
// "Return code from getdns_extension_set_libuv_loop()");
|
||||||
}
|
// return result;
|
||||||
#endif
|
// }
|
||||||
|
// #endif
|
||||||
|
// #if HAVE_LIBEV
|
||||||
|
// if (event_loop_type == LIBEV_LOOP) {
|
||||||
|
// return create_libev_base(context);
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue