event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events)
{
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
- evmap_io_active_(base, fd, events & (EV_READ|EV_WRITE|EV_CLOSED));
+
+ /* Activate any non timer events */
+ if (!(events & EV_TIMEOUT)) {
+ evmap_io_active_(base, fd, events & (EV_READ|EV_WRITE|EV_CLOSED));
+ } else {
+ /* If we want to activate timer events, loop and activate each event with
+ * the same fd in both the timeheap and common timeouts list */
+ int i;
+ unsigned u;
+ struct event *ev;
+
+ for (u = 0; u < base->timeheap.n; ++u) {
+ ev = base->timeheap.p[u];
+ if (ev->ev_fd == fd) {
+ event_active_nolock_(ev, EV_TIMEOUT, 1);
+ }
+ }
+
+ for (i = 0; i < base->n_common_timeouts; ++i) {
+ struct common_timeout_list *ctl = base->common_timeout_queues[i];
+ TAILQ_FOREACH(ev, &ctl->events,
+ ev_timeout_pos.ev_next_with_common_timeout) {
+ if (ev->ev_fd == fd) {
+ event_active_nolock_(ev, EV_TIMEOUT, 1);
+ }
+ }
+ }
+ }
+
EVBASE_RELEASE_LOCK(base, th_base_lock);
}
@param base the event_base on which to activate the events.
@param fd An fd to active events on.
- @param events One or more of EV_{READ,WRITE}.
+ @param events One or more of EV_{READ,WRITE,TIMEOUT}.
*/
EVENT2_EXPORT_SYMBOL
void event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events);
/* Trigger 2, 3, 4 */
event_base_active_by_fd(base, data->pair[0], EV_WRITE);
event_base_active_by_fd(base, data->pair[1], EV_READ);
+ event_base_active_by_fd(base, data->pair[1], EV_TIMEOUT);
#ifndef _WIN32
event_base_active_by_signal(base, SIGHUP);
#endif
tt_int_op(e2, ==, EV_WRITE | 0x10000);
tt_int_op(e3, ==, EV_READ | 0x10000);
/* Mask out EV_WRITE here, since it could be genuinely writeable. */
- tt_int_op((e4 & ~EV_WRITE), ==, EV_READ | 0x10000);
+ tt_int_op((e4 & ~EV_WRITE), ==, EV_READ | EV_TIMEOUT | 0x10000);
#ifndef _WIN32
tt_int_op(es, ==, EV_SIGNAL | 0x10000);
#endif