Show
Ignore:
Timestamp:
01/30/08 03:16:56 (11 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1201663016 +0000
git-parent:

[f59d8ed0e12bf7351fe924612229a1b69cf00fd5]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1201663016 +0000
Message:

oh my... http

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/eventer/eventer_kqueue_impl.c

    rf235ad4 re3c8f10  
    2424  noit_spinlock_t lock; 
    2525} *master_fds = NULL; 
     26static int *masks; 
    2627 
    2728typedef enum { EV_OWNED, EV_ALREADY_OWNED } ev_lock_state_t; 
     
    112113  maxfds = rlim.rlim_cur; 
    113114  master_fds = calloc(maxfds, sizeof(*master_fds)); 
     115  masks = calloc(maxfds, sizeof(*masks)); 
    114116  timed_events = calloc(1, sizeof(*timed_events)); 
    115117  noit_skiplist_init(timed_events); 
     
    126128  assert(e->mask); 
    127129  ev_lock_state_t lockstate; 
    128  
    129130  /* Timed events are simple */ 
    130131  if(e->mask == EVENTER_TIMER) { 
     
    196197  return eiq; 
    197198} 
     199static eventer_t eventer_kqueue_impl_find_fd(int fd) { 
     200  return master_fds[fd].e; 
     201} 
    198202static void eventer_kqueue_impl_loop() { 
    199203  int is_master_thread = 0; 
     
    287291    else { 
    288292      int idx; 
     293      /* loop once to clear */ 
    289294      for(idx = 0; idx < fd_cnt; idx++) { 
     295        struct kevent *ke; 
     296        ke = &ke_vec[idx]; 
     297        if(ke->flags & EV_ERROR) continue; 
     298        masks[ke->ident] = 0; 
     299      } 
     300      /* Loop again to aggregate */ 
     301      for(idx = 0; idx < fd_cnt; idx++) { 
     302        struct kevent *ke; 
     303        ke = &ke_vec[idx]; 
     304        if(ke->flags & EV_ERROR) continue; 
     305        if(ke->filter == EVFILT_READ) masks[ke->ident] |= EVENTER_READ; 
     306        if(ke->filter == EVFILT_WRITE) masks[ke->ident] |= EVENTER_WRITE; 
     307      } 
     308      /* Loop a last time to process */ 
     309      for(idx = 0; idx < fd_cnt; idx++) { 
     310        const char *cbname; 
    290311        ev_lock_state_t lockstate; 
    291312        struct kevent *ke; 
    292313        eventer_t e; 
    293         int fd, evmask, oldmask; 
     314        int fd, oldmask; 
    294315 
    295316        ke = &ke_vec[idx]; 
     
    301322        e = (eventer_t)ke->udata; 
    302323        fd = ke->ident; 
     324        if(!masks[fd]) continue; 
    303325        assert(e == master_fds[fd].e); 
    304326        lockstate = acquire_master_fd(fd); 
    305327        assert(lockstate == EV_OWNED); 
    306328 
    307         evmask = 0; 
    308         if(ke->filter == EVFILT_READ) evmask = EVENTER_READ; 
    309         if(ke->filter == EVFILT_WRITE) evmask = EVENTER_WRITE; 
    310329        gettimeofday(&__now, NULL); 
    311330        oldmask = e->mask; 
    312         newmask = e->callback(e, evmask, e->closure, &__now); 
     331        cbname = eventer_name_for_callback(e->callback); 
     332        noit_log(noit_debug, &__now, "kqueue: fire on %d/%x to %s(%p)\n", 
     333                 fd, masks[fd], cbname?cbname:"???", e->callback); 
     334        newmask = e->callback(e, masks[fd], e->closure, &__now); 
     335        masks[fd] = 0; /* indicates we've processed this fd */ 
    313336 
    314337        if(newmask) { 
     
    349372  eventer_kqueue_impl_update, 
    350373  eventer_kqueue_impl_remove_fd, 
     374  eventer_kqueue_impl_find_fd, 
    351375  eventer_kqueue_impl_loop 
    352376};