Changeset 34990

Show
Ignore:
Timestamp:
08/23/09 22:21:31 (4 years ago)
Author:
kazuho
Message:

add kqueue support

Location:
lang/c/picoev/trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/c/picoev/trunk/picoev.h

    r34989 r34990  
    165165    target->events = 0; 
    166166    target->timeout_idx = -1; 
    167     if (picoev_update_events_internal(loop, fd, events) != 0) { 
     167    if (events != 0 && picoev_update_events_internal(loop, fd, events) != 0) { 
    168168      target->loop_id = 0; 
    169169      return -1; 
     
    179179    assert(PICOEV_IS_INITED_AND_FD_IN_RANGE(fd)); 
    180180    target = picoev.fds + fd; 
    181     if (target->events != 0) { 
    182       if (picoev_update_events_internal(loop, fd, 0) != 0) { 
    183         return -1; 
    184       } 
     181    if (target->events != 0 
     182        && picoev_update_events_internal(loop, fd, 0) != 0) { 
     183      return -1; 
    185184    } 
    186185    picoev_set_timeout(loop, fd, 0); 
     
    200199  int picoev_set_events(picoev_loop* loop, int fd, int events) { 
    201200    assert(PICOEV_IS_INITED_AND_FD_IN_RANGE(fd)); 
    202     if (picoev.fds[fd].events != events) { 
    203       if (picoev_update_events_internal(loop, fd, events) != 0) { 
    204         return -1; 
    205       } 
     201    if (picoev.fds[fd].events != events 
     202        && picoev_update_events_internal(loop, fd, events) != 0) { 
     203      return -1; 
    206204    } 
    207205    return 0; 
  • lang/c/picoev/trunk/picoev_epoll.c

    r34988 r34990  
    1616  int old_events = picoev.fds[fd].events; 
    1717   
     18  assert(PICOEV_FD_BELONGS_TO_LOOP(&loop->loop, fd)); 
     19   
    1820#define CTL(m, e)                             \ 
    1921  if (epoll_ctl(loop->epfd, m, fd, e) != 0) { \ 
     
    2123  } 
    2224   
    23   if (old_events == events) { 
    24     return 0; 
    25   } 
    26   if (events != 0) { 
     25  if (events == 0) { 
     26    CTL(EPOLL_CTL_DEL, 0); 
     27  } else { 
    2728    struct epoll_event ev; 
    2829    ev.events = ((events & PICOEV_READ) != 0 ? EPOLLIN : 0) 
     
    3435      CTL(EPOLL_CTL_ADD, &ev); 
    3536    } 
    36   } else { 
    37     CTL(EPOLL_CTL_DEL, 0); 
    3837  } 
    3938