diff --git a/src/liblwevent/350_fdparams.c b/src/liblwevent/350_fdparams.c index 1e3fca1..5baa73c 100644 --- a/src/liblwevent/350_fdparams.c +++ b/src/liblwevent/350_fdparams.c @@ -44,19 +44,29 @@ int lwevent_get_autodestroy(const struct lwevent* ev) /* lwevent_set_events() * Calls epoll_ctl(EPOLL_CTL_MOD) to change the events associated with the object `ev'. Does not - * perform the call if the new events match the current events. If `old_events' is not null, stores - * the existing events before changing. Returns -1 if epoll_ctl fails. + * perform the call if the new events match the current events. Returns -1 if epoll_ctl fails. */ int lwevent_set_events(struct lwevent* ev, int events) { - if(events == ev->events) return 0; /* don't call epoll_ctl() if no change */ - return _lwevent_activate(EPOLL_CTL_MOD, ev); + struct epoll_event ee; + + /* don't call epoll_ctl() if no change */ + if(events == ev->events) return 0; + + /* try the modification */ + ee.events = events; + ee.data.ptr = ev; + if(TEMP_FAILURE_RETRY( epoll_ctl(lwevent_epoll_fd, EPOLL_CTL_MOD, ev->fd, &ee) )) return -1; + + /* update structure only if it succeeded */ + ev->events = events; + return 0; } - + /* lwevent_set_*() - * Changes attributes associated with `ev', possibly storing the old value. + * Changes attributes associated with `ev'. */ void lwevent_set_callback(struct lwevent* ev, lwevent_callback callback) {