int timed_action_unschedule(timed_action_notifier* notifier, timed_action_t* action) { int ret = epoll_ctl(notifier->epfd, EPOLL_CTL_DEL, action->tfd, NULL); ret = MIN(timer_set_expiry(action->tfd, 0, 0, 0, 0), ret); ret = MIN(close(action->tfd), ret); return ret; }
int timed_action_unschedule(timed_action_notifier* notifier, timed_action_t* action) { int ret = epoll_ctl(notifier->epfd, EPOLL_CTL_DEL, action->tfd, NULL); ret = MIN(timer_set_expiry(action->tfd, 0, 0, 0, 0), ret); ret = MIN(close(action->tfd), ret); // timed_action_free(action); //may be need to add this fuction, but dont infect some program, dont to add first //yanly150813 return ret; }
static timed_action_t* schedule_timer(timed_action_notifier* notifier, time_t sec, long nsec, time_t intsec, long intnsec, void (*timed_action_handler)(void*), void* arg) { timed_action_t* action = (timed_action_t*) malloc(sizeof(timed_action_t)); action->tfd = timerfd_create(CLOCK_REALTIME, 0); action->timed_action_handler = timed_action_handler; action->arg = arg; struct epoll_event ev; ev.events = EPOLLIN; ev.data.ptr = action; epoll_ctl(notifier->epfd, EPOLL_CTL_ADD, action->tfd, &ev); timer_set_expiry(action->tfd, sec, nsec, sec, nsec); return action; }