This addreses NULL dereference caused by discharging timed events
with a wrapped event context.
Performance investigation for high IOPs on x-series indicated
a measurable amount of time spent in adding / removing timed events
from kqueue. During this test, multiple timers are added / removed for
each SMB request. This particular library does not benefit from the high
precision kqueue allows for discharging timed events.
Hence, it's a better call to switch back to using libtevent's default
timer functions. In this case, we use the standard API to determine
the offset to the next timed event, and then use this value for the
timeout for the subsequent kevent() call.
In overload situations where we grow our kevent array and loop,
we call get a new timer offset and use this for the next kevent() call.
Due to design constraints / current usage, libtevent's timed events
use gettimeofday() to calculate offsets. In this PR I also transition to
using the lower-precision timer CLOCK_REALTIME_FAST for the sake of
efficiency, and make a similar change to timeval_current(). This provides
precision to within 1 tick.
There is also some further simplification of kqueue / aio calls.
Further investigation will be required into utilizing a monotonic clock
for timed events.