Changeset e3c8f105af17e80c10e566366bb11a9f2a510c20

Show
Ignore:
Timestamp:
01/30/08 03:16:56 (6 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
  • configure.in

    r625628a re3c8f10  
    3636        ;; 
    3737esac 
    38 SHCFLAGS="$PICFLAGS $CFLAGS" 
    3938AC_SUBST(MODULELD) 
    4039AC_SUBST(MODULEEXT) 
     
    6362LIBS="$LIBS $XML2LIBS" 
    6463AC_MSG_RESULT([$XML2LIBS]) 
     64 
     65AC_MSG_CHECKING([libserf cflags]) 
     66SERFCFLAGS="`apr-1-config --cflags --cppflags`" 
     67SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`" 
     68AC_SUBST(SERFCFLAGS) 
     69AC_MSG_RESULT([$SERFCFLAGS]) 
     70 
     71AC_MSG_CHECKING([libserf libs]) 
     72SERFLIBS="`apu-1-config --link-ld --libs` `apr-1-config --link-ld --libs`" 
     73AC_SUBST(SERFLIBS) 
     74AC_MSG_RESULT([$SERFLIBS]) 
    6575 
    6676AC_MSG_CHECKING([whether sem_init works]) 
     
    252262 
    253263CPPFLAGS='-I$(top_srcdir)/src' 
     264SHCFLAGS="$PICFLAGS $CFLAGS" 
    254265AC_SUBST(SHCFLAGS) 
    255266 
  • src/eventer/eventer.c

    rcaa7b86 re3c8f10  
    3131static noit_hash_table __func_to_name = NOIT_HASH_EMPTY; 
    3232int eventer_name_callback(const char *name, eventer_func_t f) { 
     33  void **fptr = malloc(sizeof(*fptr)); 
     34  *fptr = (void *)f; 
    3335  noit_hash_replace(&__name_to_func, strdup(name), strlen(name), f, free, NULL); 
    34   noit_hash_replace(&__func_to_name, (char *)f, sizeof(f), strdup(name), 
    35                     NULL, free); 
     36  noit_hash_replace(&__func_to_name, (char *)fptr, sizeof(*fptr), strdup(name), 
     37                    free, free); 
    3638  return 0; 
    3739} 
     
    4446const char *eventer_name_for_callback(eventer_func_t f) { 
    4547  const char *name; 
    46   if(noit_hash_retrieve(&__func_to_name, (char *)f, sizeof(f), (void **)&name)) 
     48  if(noit_hash_retrieve(&__func_to_name, (char *)&f, sizeof(f), (void **)&name)) 
    4749    return name; 
    4850  return NULL; 
  • src/eventer/eventer.h

    rcaa7b86 re3c8f10  
    6767  void              (*update)(eventer_t e); 
    6868  eventer_t         (*remove_fd)(int fd); 
     69  eventer_t         (*find_fd)(int fd); 
    6970  int               (*loop)(); 
    7071} *eventer_impl_t; 
     
    8182#define eventer_update        __eventer->update 
    8283#define eventer_remove_fd     __eventer->remove_fd 
    83 #define eventer_attach        __eventer->attach 
     84#define eventer_find_fd       __eventer->find_fd 
    8485#define eventer_loop          __eventer->loop 
    8586 
  • 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}; 
  • src/modules/Makefile.in

    r7e43d37 re3c8f10  
    1616top_srcdir=@top_srcdir@ 
    1717 
    18 MODULES=ping_icmp.@MODULEEXT@ 
     18MODULES=ping_icmp.@MODULEEXT@ http.@MODULEEXT@ 
    1919 
    2020all:    $(MODULES) 
     21 
     22http.@MODULEEXT@:       http.lo 
     23        $(MODULELD) $(LDFLAGS) -o $@ http.lo @SERFLIBS@ ../serf/.libs/libserf-0.a -lz -lssl -lcrypto 
     24 
     25http.lo:        http.c 
     26        $(CC) $(CPPFLAGS) $(SHCFLAGS) -I$(top_srcdir)/src/serf @SERFCFLAGS@ -c http.c -o $@ 
    2127 
    2228.lo.@MODULEEXT@: 
  • src/modules/ping_icmp.c

    rfb90c74 re3c8f10  
    5656} ping_icmp_data_t; 
    5757 
    58 static int ping_icmp_onload(noit_module_t *self) { 
    59   nlerr = noit_log_stream_find("error/ping_icmp"); 
    60   nldeb = noit_log_stream_find("debug/ping_icmp"); 
    61   if(!nlerr) nlerr = noit_stderr; 
    62   if(!nldeb) nldeb = noit_debug; 
    63   return 0; 
    64 } 
    6558static int ping_icmp_config(noit_module_t *self, noit_hash_table *options) { 
    6659  return 0; 
     
    494487} 
    495488 
     489static int ping_icmp_onload(noit_module_t *self) { 
     490  nlerr = noit_log_stream_find("error/ping_icmp"); 
     491  nldeb = noit_log_stream_find("debug/ping_icmp"); 
     492  if(!nlerr) nlerr = noit_stderr; 
     493  if(!nldeb) nldeb = noit_debug; 
     494  eventer_name_callback("ping_icmp/recur_handler", ping_icmp_recur_handler); 
     495  eventer_name_callback("ping_icmp/timeout", ping_icmp_timeout); 
     496  eventer_name_callback("ping_icmp/handler", ping_icmp_handler); 
     497  return 0; 
     498} 
    496499noit_module_t ping_icmp = { 
    497500  NOIT_MODULE_MAGIC, 
  • src/noit_conf.c

    r80235b3 re3c8f10  
    125125                                            int *cnt) { 
    126126  int i; 
    127   noit_conf_section_t *sections
     127  noit_conf_section_t *sections = NULL
    128128  xmlXPathObjectPtr pobj; 
    129129  xmlXPathContextPtr current_ctxt; 
  • src/noit_poller.c

    rf59d8ed re3c8f10  
    9696        continue; 
    9797      } 
     98    } 
     99    if(timeout >= period) { 
     100      noit_log(noit_stderr, NULL, "check uuid: '%s' timeout > period\n", uuid_str); 
     101      timeout = period/2; 
    98102    } 
    99103    options = noit_conf_get_hash(sec[i], "config"); 
  • src/sample.conf

    rfb90c74 re3c8f10  
    99      <image>ping_icmp</image> 
    1010      <name>ping_icmp</name> 
     11      <config> 
     12        <key1>value2</key1> 
     13        <key2>value2</key2> 
     14      </config> 
     15    </module> 
     16    <module> 
     17      <image>http</image> 
     18      <name>http</name> 
    1119      <config> 
    1220        <key1>value2</key1> 
     
    3644      </check> 
    3745    </checkgroup> 
     46    <checkgroup> 
     47      <module>http</module> 
     48      <period>2000</period> 
     49      <timeout>1000</timeout> 
     50      <check uuid="1b4e28ba-2fa1-11d2-883f-b9a761bde3fc"> 
     51        <target>66.225.209.7</target> 
     52      </check> 
     53    </checkgroup> 
    3854  </checks> 
    3955</noit>