mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 14:53:15 -05:00
- Fix to use event_assign with libevent for thread-safety.
git-svn-id: file:///svn/unbound/trunk@5149 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
348cbab016
commit
2b47ca080e
5 changed files with 61 additions and 0 deletions
|
|
@ -86,6 +86,10 @@
|
|||
if you don't. */
|
||||
#undef HAVE_DECL_ARC4RANDOM_UNIFORM
|
||||
|
||||
/* Define to 1 if you have the declaration of `evsignal_assign', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_EVSIGNAL_ASSIGN
|
||||
|
||||
/* Define to 1 if you have the declaration of `inet_ntop', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_INET_NTOP
|
||||
|
|
@ -166,6 +170,9 @@
|
|||
/* Define to 1 if you have the `ERR_load_crypto_strings' function. */
|
||||
#undef HAVE_ERR_LOAD_CRYPTO_STRINGS
|
||||
|
||||
/* Define to 1 if you have the `event_assign' function. */
|
||||
#undef HAVE_EVENT_ASSIGN
|
||||
|
||||
/* Define to 1 if you have the `event_base_free' function. */
|
||||
#undef HAVE_EVENT_BASE_FREE
|
||||
|
||||
|
|
|
|||
29
configure
vendored
29
configure
vendored
|
|
@ -19013,6 +19013,35 @@ _ACEOF
|
|||
fi
|
||||
done
|
||||
# only in libev. (tested on 4.00)
|
||||
for ac_func in event_assign
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "event_assign" "ac_cv_func_event_assign"
|
||||
if test "x$ac_cv_func_event_assign" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_EVENT_ASSIGN 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
# in libevent, for thread-safety
|
||||
ac_fn_c_check_decl "$LINENO" "evsignal_assign" "ac_cv_have_decl_evsignal_assign" "$ac_includes_default
|
||||
#ifdef HAVE_EVENT_H
|
||||
# include <event.h>
|
||||
#else
|
||||
# include \"event2/event.h\"
|
||||
#endif
|
||||
|
||||
"
|
||||
if test "x$ac_cv_have_decl_evsignal_assign" = xyes; then :
|
||||
ac_have_decl=1
|
||||
else
|
||||
ac_have_decl=0
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_DECL_EVSIGNAL_ASSIGN $ac_have_decl
|
||||
_ACEOF
|
||||
|
||||
PC_LIBEVENT_DEPENDENCY="libevent"
|
||||
|
||||
if test -n "$BAK_LDFLAGS_SET"; then
|
||||
|
|
|
|||
|
|
@ -1200,6 +1200,14 @@ large outgoing port ranges. ])
|
|||
AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
|
||||
AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
|
||||
AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
|
||||
AC_CHECK_FUNCS([event_assign]) # in libevent, for thread-safety
|
||||
AC_CHECK_DECLS([evsignal_assign], [], [], [AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_EVENT_H
|
||||
# include <event.h>
|
||||
#else
|
||||
# include "event2/event.h"
|
||||
#endif
|
||||
])
|
||||
PC_LIBEVENT_DEPENDENCY="libevent"
|
||||
AC_SUBST(PC_LIBEVENT_DEPENDENCY)
|
||||
if test -n "$BAK_LDFLAGS_SET"; then
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
8 April 2019: Wouter
|
||||
- Fix to use event_assign with libevent for thread-safety.
|
||||
|
||||
5 April 2019: Wouter
|
||||
- Fix to reinit event structure for accepted TCP (and TLS) sockets.
|
||||
|
||||
|
|
|
|||
|
|
@ -295,11 +295,18 @@ ub_event_new(struct ub_event_base* base, int fd, short bits,
|
|||
if (!ev)
|
||||
return NULL;
|
||||
|
||||
#ifndef HAVE_EVENT_ASSIGN
|
||||
event_set(ev, fd, NATIVE_BITS(bits), NATIVE_BITS_CB(cb), arg);
|
||||
if (event_base_set(AS_EVENT_BASE(base), ev) != 0) {
|
||||
free(ev);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (event_assign(ev, AS_EVENT_BASE(base), fd, bits, cb, arg) != 0) {
|
||||
free(ev);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return AS_UB_EVENT(ev);
|
||||
}
|
||||
|
||||
|
|
@ -312,11 +319,18 @@ ub_signal_new(struct ub_event_base* base, int fd,
|
|||
if (!ev)
|
||||
return NULL;
|
||||
|
||||
#if !HAVE_DECL_EVSIGNAL_ASSIGN
|
||||
signal_set(ev, fd, NATIVE_BITS_CB(cb), arg);
|
||||
if (event_base_set(AS_EVENT_BASE(base), ev) != 0) {
|
||||
free(ev);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (evsignal_assign(ev, AS_EVENT_BASE(base), fd, cb, arg) != 0) {
|
||||
free(ev);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return AS_UB_EVENT(ev);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue