o Rename the "class" field in evdns_server_request to dns_question_class, so that it won't break compilation under C++. Use a macro so that old code won't break. Mark the macro as deprecated.
o Fix DNS unit tests so that having a DNS server with broken IPv6 support is no longer cause for aborting the unit tests.
o Make event_base_free() succeed even if there are pending non-internal events on a base. This may still leak memory and fds, but at least it no longer crashes.
+ o Post-process the config.h file into a new, installed event-config.h file that we can install, and whose macros will be safe to include in header files.
+ o Remove the long-deprecated acconfig.h file.
+ o Do not require #include <sys/types.h> before #include <event.h>.
+ o Add new evutil_timer* functions to wrap (or replace) the regular timeval manipulation functions.
+
endif
+BUILT_SOURCES = event-config.h
+
+event-config.h: config.h
+ echo '/* event-config.h' > $@
+ echo ' * Generated by autoconf; post-processed by libevent.' >> $@
+ echo ' * Do not edit this file.' >> $@
+ echo ' * Do not rely on macros in this file existing in later versions.'>> $@
+ echo ' */' >> $@
+ echo '#ifndef _EVENT_CONFIG_H_' >> $@
+ echo '#define _EVENT_CONFIG_H_' >> $@
+
+ sed -e 's/#define /#define _EVENT_/' \
+ -e 's/#undef /#undef _EVENT_/' \
+ -e 's/#ifndef /#ifndef _EVENT_/' < config.h >> $@
+ echo "#endif" >> $@
+
CORE_SRC = event.c buffer.c evbuffer.c log.c evutil.c $(SYS_SRC)
EXTRA_SRC = event_tagging.c http.c evhttp.h http-internal.h evdns.c \
evdns.h evrpc.c evrpc.h evrpc-internal.h \
libevent_extra_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS)
libevent_extra_la_LDFLAGS = -release $(RELEASE) -version-info $(VERSION_INFO)
-include_HEADERS = event.h evhttp.h evdns.h evrpc.h evutil.h
+include_HEADERS = event.h evhttp.h evdns.h evrpc.h evutil.h event-config.h
INCLUDES = -I$(srcdir)/compat $(SYS_INCLUDES)
+++ /dev/null
-/* Define if timeradd is defined in <sys/time.h> */
-#undef HAVE_TIMERADD
-#ifndef HAVE_TIMERADD
-#undef timersub
-#define timeradd(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
- if ((vvp)->tv_usec >= 1000000) { \
- (vvp)->tv_sec++; \
- (vvp)->tv_usec -= 1000000; \
- } \
- } while (0)
-#define timersub(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
- if ((vvp)->tv_usec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_usec += 1000000; \
- } \
- } while (0)
-#endif /* !HAVE_TIMERADD */
-
-#undef HAVE_TIMERCLEAR
-#ifndef HAVE_TIMERCLEAR
-#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
-#endif
-
-#undef HAVE_TIMERCMP
-#ifndef HAVE_TIMERCMP
-#undef timercmp
-#define timercmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \
- ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
- ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#endif
-
-#undef HAVE_TIMERISSET
-#ifndef HAVE_TIMERISSET
-#undef timerisset
-#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#endif
-
-/* Define if TAILQ_FOREACH is defined in <sys/queue.h> */
-#undef HAVE_TAILQFOREACH
-#ifndef HAVE_TAILQFOREACH
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-#define TAILQ_END(head) NULL
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-#define TAILQ_FOREACH(var, head, field) \
- for((var) = TAILQ_FIRST(head); \
- (var) != TAILQ_END(head); \
- (var) = TAILQ_NEXT(var, field))
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- (elm)->field.tqe_next = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
-} while (0)
-#endif /* TAILQ_FOREACH */
-
#include <stdarg.h>
#endif
+#include "evutil.h"
#include "event.h"
/* prototypes */
struct timeval tv, *ptv = NULL;
if (timeout) {
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = timeout;
ptv = &tv;
}
extern "C" {
#endif
+#include "config.h"
#include "min_heap.h"
#include "evsignal.h"
struct min_heap timeheap;
};
+/* Internal use only: Functions that might be missing from <sys/queue.h> */
+#ifndef HAVE_TAILQFOREACH
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_END(head) NULL
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+#define TAILQ_FOREACH(var, head, field) \
+ for((var) = TAILQ_FIRST(head); \
+ (var) != TAILQ_END(head); \
+ (var) = TAILQ_NEXT(var, field))
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (0)
+#endif /* TAILQ_FOREACH */
+
#ifdef __cplusplus
}
#endif
#include "event.h"
#include "event-internal.h"
+#include "evutil.h"
#include "log.h"
#ifdef HAVE_EVENT_PORTS
* if we have active events, we just poll new events
* without waiting.
*/
- timerclear(&tv);
+ evutil_timerclear(&tv);
}
/* If we have no events, we just exit */
if (events == EV_TIMEOUT) {
if (tv == NULL) {
- timerclear(&etv);
+ evutil_timerclear(&etv);
tv = &etv;
}
/* See if there is a timeout that we should report */
if (tv != NULL && (flags & event & EV_TIMEOUT)) {
gettime(&now);
- timersub(&ev->ev_timeout, &now, &res);
+ evutil_timersub(&ev->ev_timeout, &now, &res);
/* correctly remap to real time */
gettimeofday(&now, NULL);
- timeradd(&now, &res, tv);
+ evutil_timeradd(&now, &res, tv);
}
return (flags & event);
}
gettime(&now);
- timeradd(&now, tv, &ev->ev_timeout);
+ evutil_timeradd(&now, tv, &ev->ev_timeout);
event_debug((
"event_add: timeout in %d seconds, call %p",
if (gettime(&now) == -1)
return (-1);
- if (timercmp(&ev->ev_timeout, &now, <=)) {
- timerclear(tv);
+ if (evutil_timercmp(&ev->ev_timeout, &now, <=)) {
+ evutil_timerclear(tv);
return (0);
}
- timersub(&ev->ev_timeout, &now, tv);
+ evutil_timersub(&ev->ev_timeout, &now, tv);
assert(tv->tv_sec >= 0);
assert(tv->tv_usec >= 0);
/* Check if time is running backwards */
gettime(tv);
- if (timercmp(tv, &base->event_tv, >=)) {
+ if (evutil_timercmp(tv, &base->event_tv, >=)) {
base->event_tv = *tv;
return;
}
event_debug(("%s: time is running backwards, corrected",
__func__));
- timersub(&base->event_tv, tv, &off);
+ evutil_timersub(&base->event_tv, tv, &off);
/*
* We can modify the key element of the node without destroying
size = base->timeheap.n;
for (; size-- > 0; ++pev) {
struct timeval *tv = &(**pev).ev_timeout;
- timersub(tv, &off, tv);
+ evutil_timersub(tv, &off, tv);
}
}
gettime(&now);
while ((ev = min_heap_top(&base->timeheap))) {
- if (timercmp(&ev->ev_timeout, &now, >))
+ if (evutil_timercmp(&ev->ev_timeout, &now, >))
break;
event_queue_remove(base, ev, EVLIST_TIMEOUT);
extern "C" {
#endif
+#include <event-config.h>
+#ifdef _EVENT_HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
#include <sys/time.h>
#include <stdint.h>
#include <stdarg.h>
#include "evrpc.h"
#include "evrpc-internal.h"
#include "evhttp.h"
+#include "evutil.h"
#include "log.h"
struct evrpc_base *
* a timeout after which the whole rpc is going to be aborted.
*/
struct timeval tv;
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = pool->timeout;
evtimer_add(&ctx->ev_timeout, &tv);
}
extern "C" {
#endif
+#include <event-config.h>
+#ifdef _EVENT_HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
int evutil_socketpair(int d, int type, int protocol, int sv[2]);
int evutil_make_socket_nonblocking(int sock);
#ifdef WIN32
do { errno = (errcode); } while (0)
#endif
+/*
+ * Manipulation functions for struct timeval
+ */
+#ifdef _EVENT_HAVE_TIMERADD
+#define evutil_timeradd(tvp, uvp, vvp) timeradd((tvp), (uvp), (vvp))
+#define evutil_timersub(tvp, uvp, vvp) timersub((tvp), (uvp), (vvp))
+#else
+#define evutil_timeradd(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if ((vvp)->tv_usec >= 1000000) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define evutil_timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif /* !_EVENT_HAVE_HAVE_TIMERADD */
+
+#ifdef _EVENT_HAVE_TIMERCLEAR
+#define evutil_timerclear(tvp) timerclear(tvp)
+#else
+#define evutil_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#endif
+
+#ifdef _EVENT_HAVE_TIMERCMP
+#define evutil_timercmp(tvp, uvp, cmp) timercmp((tvp), (uvp), cmp)
+#else
+#define evutil_timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
+
+#ifdef _EVENT_HAVE_TIMERISSET
+#define evutil_timerisset(tvp) timerisset(tvp)
+#else
+#define evutil_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#endif
+
#ifdef __cplusplus
}
#endif
if (timeout != 0) {
struct timeval tv;
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = timeout != -1 ? timeout : default_timeout;
event_add(ev, &tv);
} else {
#include <errno.h>
#include <event.h>
+#include <evutil.h>
int lasttime;
newtime - lasttime);
lasttime = newtime;
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = 2;
event_add(timeout, &tv);
}
/* Initalize one event */
evtimer_set(&timeout, timeout_cb, &timeout);
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = 2;
event_add(&timeout, &tv);
if (xcount != count) fprintf(stderr, "Xcount: %d, Rcount: %d\n", xcount, count);
}
- timersub(&te, &ts, &te);
+ evutil_timersub(&te, &ts, &te);
return (&te);
}
int diff;
gettimeofday(&tcalled, NULL);
- if (timercmp(&tcalled, &tset, >))
- timersub(&tcalled, &tset, &tv);
+ if (evutil_timercmp(&tcalled, &tset, >))
+ evutil_timersub(&tcalled, &tset, &tv);
else
- timersub(&tset, &tcalled, &tv);
+ evutil_timersub(&tset, &tcalled, &tv);
diff = tv.tv_sec*1000 + tv.tv_usec/1000 - SECONDS * 1000;
if (diff < 0)
gettimeofday(&tv_start, NULL);
event_dispatch();
gettimeofday(&tv_end, NULL);
- timersub(&tv_end, &tv_start, &tv_end);
+ evutil_timersub(&tv_end, &tv_start, &tv_end);
evtimer_del(&ev);
pri->count++;
- timerclear(&tv);
+ evutil_timerclear(&tv);
event_add(&pri->ev, &tv);
}
exit(1);
}
- timerclear(&tv);
+ evutil_timerclear(&tv);
if (event_add(&one.ev, &tv) == -1)
exit(1);
write(pair[0], TEST1, strlen(TEST1)+1);
/* Setup the loop termination */
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = 1;
event_loopexit(&tv);
/* Now insert some corruption into the tag length field */
evbuffer_drain(tmp, -1);
- timerclear(&tv);
+ evutil_timerclear(&tv);
tv.tv_sec = 1;
evtag_marshal_timeval(tmp, 0, &tv);
evbuffer_add(tmp, buffer, sizeof(buffer));
}
gettimeofday(&tv_end, NULL);
- timersub(&tv_end, &tv_start, &tv_end);
+ evutil_timersub(&tv_end, &tv_start, &tv_end);
fprintf(stderr, "(%.1f us/add) ",
(float)tv_end.tv_sec/(float)i * 1000000.0 +
tv_end.tv_usec / (float)i);