Otherwise, requests initially sent to a failing nameserver would
stay there indefinitely, even if other nameservers would work.
Fix for sourceforge bug 3518439
Previously, we treated EINVAL as the only errno that indicated a
broken accept4. But EINVAL only appears when one of the SOCK_*
options isn't supported. If the accept4 syscall itself isn't there,
we'll get an ENOSYS.
Reported by Azat Khuzhin.
the function do_read() will call SSL_read(), and if successful, will
call _bufferevent_run_readcb() before returning to consider_reading().
consider_reading() will then check SSL_pending() to make sure all
pending data has also been read. If it does not, do_read() is called
again.
The issue with this is the possibility that the function that is
executed by _bufferevent_run_readcb() called
bufferevent_disable(ssl_bev, EV_READ) before the second do_read(); In
this case, the users read callback is executed a second time. This is
potentially bad for applications that expect the bufferevent to stay
disabled until further notice. (this is why running openssl bufferevents
without DEFER_CALLBACKS has always been troublesome).
This approach should make the creation of the file more atomic, to
fix a bug reported by Dinh.
This patch has one change from Zack's original version: it avoids
$<, since Dave Hart tells me he thinks that's not so portable.
(commit message by nickm)
This approach should make the creation of the file more atomic, to
fix a bug reported by Dinh.
This patch has one change from Zack's original version: it avoids
$<, since Dave Hart tells me he thinks that's not so portable.
(commit message by nickm)
The epoll interface ordinarily gives us one-millisecond
precision, so on Linux it makes perfect sense to use the
CLOCK_MONOTONIC_COARSE timer. But when the user has set the new
PRECISE_TIMER flag for an event_base (either by the
EVENT_BASE_FLAG_PRECISE_TIMER flag, or by the EVENT_PRECISE_TIMER
environment variable), they presumably want finer granularity.
On not-too-old Linuxes, we can achieve this using the Timerfd
mechanism, which accepts nanosecond granularity and understands
posix clocks. It's a little more expensive than just calling
epoll_wait(), so we won't do it by default.
Fixes an issue reported on libevent-users in the thread "a dead
looping bug when changing system time backward". Previously, if time
jumped forward 1 hour[*] and we had a one-second periodic timer event,
that event would get invoked 3600 times. That's almost certainly not
what anybody wants.
In a future version of Libevent, we should expose the amount of time
that the callbac kwould have been invoked somehow.
[*] Forward time jumps can happen with nonmonotonic clocks, or with
clocks that jump on suspend/resume. It can also happen from
Libevent's point of view if the user exits from event_base_loop() and
doesn't call it again for a while.
There are a bunch of backends that can give us a reasonably good
monotonic timer quickly, or a very precise monotonic timer less
quickly. For example, Linux has CLOCK_MONOTONIC_COARSE (1msec
precision), which is over twice as fast as CLOCK_MONOTONIC. Since
epoll only lets you wait with 1msec precision,
CLOCK_MONOTONIC_COARSE is a clear win.
On Windows, you've got GetTickCount{,64}() which is fast, and
QueryPerformanceCounter, which is precise but slow.
Note that even in the cases where the underlying timer claims to
have nanosecond resolution, we're still not exposing that via
Libevent.
Note also that "Precision" isn't the same as "Resolution" or
"Accuracy". A timer's precision is the smallest change that the
clock will register; a timer's resolution is the fineness of its
underlying representation; a timer's accuracy is how much it drifts
with respect to "Real Time", whatever that means. (Terms and
definitions from PEP 418.)
The use_monotonic field used to be a static field set up at library
setup. Unfortunately, this makes it hard to give the user a way to
make speed/accuracy tradeoffs about time. Moving it into event_base
should let the clock implementation become configurable.
Sufficiently recent kqueue implementations have an EVFILT_USER filter
that we can use to wake up an event base from another thread. When
it's supported, we now use this mechanism rather than our old
(pipe-based) mechanism. This should save some time and complications
on newer OSX and freebsds.