Changeset e3c8f105af17e80c10e566366bb11a9f2a510c20
- Timestamp:
- 01/30/08 03:16:56
(5 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
| r625628a |
re3c8f10 |
|
| 36 | 36 | ;; |
|---|
| 37 | 37 | esac |
|---|
| 38 | | SHCFLAGS="$PICFLAGS $CFLAGS" |
|---|
| 39 | 38 | AC_SUBST(MODULELD) |
|---|
| 40 | 39 | AC_SUBST(MODULEEXT) |
|---|
| … | … | |
| 63 | 62 | LIBS="$LIBS $XML2LIBS" |
|---|
| 64 | 63 | AC_MSG_RESULT([$XML2LIBS]) |
|---|
| | 64 | |
|---|
| | 65 | AC_MSG_CHECKING([libserf cflags]) |
|---|
| | 66 | SERFCFLAGS="`apr-1-config --cflags --cppflags`" |
|---|
| | 67 | SERFCFLAGS="$SERFCFLAGS -I`apu-1-config --includedir` -I`apr-1-config --includedir`" |
|---|
| | 68 | AC_SUBST(SERFCFLAGS) |
|---|
| | 69 | AC_MSG_RESULT([$SERFCFLAGS]) |
|---|
| | 70 | |
|---|
| | 71 | AC_MSG_CHECKING([libserf libs]) |
|---|
| | 72 | SERFLIBS="`apu-1-config --link-ld --libs` `apr-1-config --link-ld --libs`" |
|---|
| | 73 | AC_SUBST(SERFLIBS) |
|---|
| | 74 | AC_MSG_RESULT([$SERFLIBS]) |
|---|
| 65 | 75 | |
|---|
| 66 | 76 | AC_MSG_CHECKING([whether sem_init works]) |
|---|
| … | … | |
| 252 | 262 | |
|---|
| 253 | 263 | CPPFLAGS='-I$(top_srcdir)/src' |
|---|
| | 264 | SHCFLAGS="$PICFLAGS $CFLAGS" |
|---|
| 254 | 265 | AC_SUBST(SHCFLAGS) |
|---|
| 255 | 266 | |
|---|
| rcaa7b86 |
re3c8f10 |
|
| 31 | 31 | static noit_hash_table __func_to_name = NOIT_HASH_EMPTY; |
|---|
| 32 | 32 | int eventer_name_callback(const char *name, eventer_func_t f) { |
|---|
| | 33 | void **fptr = malloc(sizeof(*fptr)); |
|---|
| | 34 | *fptr = (void *)f; |
|---|
| 33 | 35 | 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); |
|---|
| 36 | 38 | return 0; |
|---|
| 37 | 39 | } |
|---|
| … | … | |
| 44 | 46 | const char *eventer_name_for_callback(eventer_func_t f) { |
|---|
| 45 | 47 | 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)) |
|---|
| 47 | 49 | return name; |
|---|
| 48 | 50 | return NULL; |
|---|
| rcaa7b86 |
re3c8f10 |
|
| 67 | 67 | void (*update)(eventer_t e); |
|---|
| 68 | 68 | eventer_t (*remove_fd)(int fd); |
|---|
| | 69 | eventer_t (*find_fd)(int fd); |
|---|
| 69 | 70 | int (*loop)(); |
|---|
| 70 | 71 | } *eventer_impl_t; |
|---|
| … | … | |
| 81 | 82 | #define eventer_update __eventer->update |
|---|
| 82 | 83 | #define eventer_remove_fd __eventer->remove_fd |
|---|
| 83 | | #define eventer_attach __eventer->attach |
|---|
| | 84 | #define eventer_find_fd __eventer->find_fd |
|---|
| 84 | 85 | #define eventer_loop __eventer->loop |
|---|
| 85 | 86 | |
|---|
| rf235ad4 |
re3c8f10 |
|
| 24 | 24 | noit_spinlock_t lock; |
|---|
| 25 | 25 | } *master_fds = NULL; |
|---|
| | 26 | static int *masks; |
|---|
| 26 | 27 | |
|---|
| 27 | 28 | typedef enum { EV_OWNED, EV_ALREADY_OWNED } ev_lock_state_t; |
|---|
| … | … | |
| 112 | 113 | maxfds = rlim.rlim_cur; |
|---|
| 113 | 114 | master_fds = calloc(maxfds, sizeof(*master_fds)); |
|---|
| | 115 | masks = calloc(maxfds, sizeof(*masks)); |
|---|
| 114 | 116 | timed_events = calloc(1, sizeof(*timed_events)); |
|---|
| 115 | 117 | noit_skiplist_init(timed_events); |
|---|
| … | … | |
| 126 | 128 | assert(e->mask); |
|---|
| 127 | 129 | ev_lock_state_t lockstate; |
|---|
| 128 | | |
|---|
| 129 | 130 | /* Timed events are simple */ |
|---|
| 130 | 131 | if(e->mask == EVENTER_TIMER) { |
|---|
| … | … | |
| 196 | 197 | return eiq; |
|---|
| 197 | 198 | } |
|---|
| | 199 | static eventer_t eventer_kqueue_impl_find_fd(int fd) { |
|---|
| | 200 | return master_fds[fd].e; |
|---|
| | 201 | } |
|---|
| 198 | 202 | static void eventer_kqueue_impl_loop() { |
|---|
| 199 | 203 | int is_master_thread = 0; |
|---|
| … | … | |
| 287 | 291 | else { |
|---|
| 288 | 292 | int idx; |
|---|
| | 293 | /* loop once to clear */ |
|---|
| 289 | 294 | 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; |
|---|
| 290 | 311 | ev_lock_state_t lockstate; |
|---|
| 291 | 312 | struct kevent *ke; |
|---|
| 292 | 313 | eventer_t e; |
|---|
| 293 | | int fd, evmask, oldmask; |
|---|
| | 314 | int fd, oldmask; |
|---|
| 294 | 315 | |
|---|
| 295 | 316 | ke = &ke_vec[idx]; |
|---|
| … | … | |
| 301 | 322 | e = (eventer_t)ke->udata; |
|---|
| 302 | 323 | fd = ke->ident; |
|---|
| | 324 | if(!masks[fd]) continue; |
|---|
| 303 | 325 | assert(e == master_fds[fd].e); |
|---|
| 304 | 326 | lockstate = acquire_master_fd(fd); |
|---|
| 305 | 327 | assert(lockstate == EV_OWNED); |
|---|
| 306 | 328 | |
|---|
| 307 | | evmask = 0; |
|---|
| 308 | | if(ke->filter == EVFILT_READ) evmask = EVENTER_READ; |
|---|
| 309 | | if(ke->filter == EVFILT_WRITE) evmask = EVENTER_WRITE; |
|---|
| 310 | 329 | gettimeofday(&__now, NULL); |
|---|
| 311 | 330 | 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 */ |
|---|
| 313 | 336 | |
|---|
| 314 | 337 | if(newmask) { |
|---|
| … | … | |
| 349 | 372 | eventer_kqueue_impl_update, |
|---|
| 350 | 373 | eventer_kqueue_impl_remove_fd, |
|---|
| | 374 | eventer_kqueue_impl_find_fd, |
|---|
| 351 | 375 | eventer_kqueue_impl_loop |
|---|
| 352 | 376 | }; |
|---|
| r7e43d37 |
re3c8f10 |
|
| 16 | 16 | top_srcdir=@top_srcdir@ |
|---|
| 17 | 17 | |
|---|
| 18 | | MODULES=ping_icmp.@MODULEEXT@ |
|---|
| | 18 | MODULES=ping_icmp.@MODULEEXT@ http.@MODULEEXT@ |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | all: $(MODULES) |
|---|
| | 21 | |
|---|
| | 22 | http.@MODULEEXT@: http.lo |
|---|
| | 23 | $(MODULELD) $(LDFLAGS) -o $@ http.lo @SERFLIBS@ ../serf/.libs/libserf-0.a -lz -lssl -lcrypto |
|---|
| | 24 | |
|---|
| | 25 | http.lo: http.c |
|---|
| | 26 | $(CC) $(CPPFLAGS) $(SHCFLAGS) -I$(top_srcdir)/src/serf @SERFCFLAGS@ -c http.c -o $@ |
|---|
| 21 | 27 | |
|---|
| 22 | 28 | .lo.@MODULEEXT@: |
|---|
| rfb90c74 |
re3c8f10 |
|
| 56 | 56 | } ping_icmp_data_t; |
|---|
| 57 | 57 | |
|---|
| 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 | | } |
|---|
| 65 | 58 | static int ping_icmp_config(noit_module_t *self, noit_hash_table *options) { |
|---|
| 66 | 59 | return 0; |
|---|
| … | … | |
| 494 | 487 | } |
|---|
| 495 | 488 | |
|---|
| | 489 | static 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 | } |
|---|
| 496 | 499 | noit_module_t ping_icmp = { |
|---|
| 497 | 500 | NOIT_MODULE_MAGIC, |
|---|
| r80235b3 |
re3c8f10 |
|
| 125 | 125 | int *cnt) { |
|---|
| 126 | 126 | int i; |
|---|
| 127 | | noit_conf_section_t *sections; |
|---|
| | 127 | noit_conf_section_t *sections = NULL; |
|---|
| 128 | 128 | xmlXPathObjectPtr pobj; |
|---|
| 129 | 129 | xmlXPathContextPtr current_ctxt; |
|---|
| rf59d8ed |
re3c8f10 |
|
| 96 | 96 | continue; |
|---|
| 97 | 97 | } |
|---|
| | 98 | } |
|---|
| | 99 | if(timeout >= period) { |
|---|
| | 100 | noit_log(noit_stderr, NULL, "check uuid: '%s' timeout > period\n", uuid_str); |
|---|
| | 101 | timeout = period/2; |
|---|
| 98 | 102 | } |
|---|
| 99 | 103 | options = noit_conf_get_hash(sec[i], "config"); |
|---|
| rfb90c74 |
re3c8f10 |
|
| 9 | 9 | <image>ping_icmp</image> |
|---|
| 10 | 10 | <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> |
|---|
| 11 | 19 | <config> |
|---|
| 12 | 20 | <key1>value2</key1> |
|---|
| … | … | |
| 36 | 44 | </check> |
|---|
| 37 | 45 | </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> |
|---|
| 38 | 54 | </checks> |
|---|
| 39 | 55 | </noit> |
|---|