summaryrefslogtreecommitdiffstats
path: root/third_party/libevent/event.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libevent/event.c')
-rw-r--r--third_party/libevent/event.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/third_party/libevent/event.c b/third_party/libevent/event.c
index 3396b35..726ffad 100644
--- a/third_party/libevent/event.c
+++ b/third_party/libevent/event.c
@@ -108,10 +108,7 @@ const struct eventop *eventops[] = {
struct event_base *current_base = NULL;
extern struct event_base *evsignal_base;
static int use_monotonic;
-
-/* Handle signals - This is a deprecated interface */
-int (*event_sigcb)(void); /* Signal callback when gotsig is set */
-volatile sig_atomic_t event_gotsig; /* Set in signal handler */
+static int use_monotonic_initialized;
/* Prototypes */
static void event_queue_insert(struct event_base *, struct event *, int);
@@ -128,10 +125,14 @@ static void
detect_monotonic(void)
{
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
+ if (use_monotonic_initialized)
+ return;
+
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
use_monotonic = 1;
+ use_monotonic_initialized = 1;
#endif
}
@@ -179,9 +180,6 @@ event_base_new(void)
if ((base = calloc(1, sizeof(struct event_base))) == NULL)
event_err(1, "%s: calloc", __func__);
- event_sigcb = NULL;
- event_gotsig = 0;
-
detect_monotonic();
gettime(base, &base->event_tv);
@@ -385,7 +383,7 @@ event_process_active(struct event_base *base)
ncalls--;
ev->ev_ncalls = ncalls;
(*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
- if (event_gotsig || base->event_break)
+ if (base->event_break)
return;
}
}
@@ -472,7 +470,7 @@ event_base_loop(struct event_base *base, int flags)
struct timeval *tv_p;
int res, done;
- if (&base->sig.ev_signal_added)
+ if (base->sig.ev_signal_added)
evsignal_base = base;
done = 0;
while (!done) {
@@ -487,18 +485,6 @@ event_base_loop(struct event_base *base, int flags)
break;
}
- /* You cannot use this interface for multi-threaded apps */
- while (event_gotsig) {
- event_gotsig = 0;
- if (event_sigcb) {
- res = (*event_sigcb)();
- if (res == -1) {
- errno = EINTR;
- return (-1);
- }
- }
- }
-
timeout_correct(base, &tv);
tv_p = &tv;