Changeset 6210da7ee0e2ed143d71a8e00b709f16e71059f8
- Timestamp:
- 03/17/09 21:10:22
(9 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1237324222 +0000
- git-parent:
[f99cf462c3bf905a727087a97e5c305a52256d5e]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1237324222 +0000
- Message:
various changes to avoid dereferencing type-punned pointers and breaking strict-aliasing rules, refs #34
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
r928d57f |
r6210da7 |
|
38 | 38 | } |
---|
39 | 39 | eventer_func_t eventer_callback_for_name(const char *name) { |
---|
40 | | eventer_func_t f; |
---|
41 | | if(noit_hash_retrieve(&__name_to_func, name, strlen(name), (void **)&f)) |
---|
42 | | return f; |
---|
| 40 | void *vf; |
---|
| 41 | if(noit_hash_retrieve(&__name_to_func, name, strlen(name), &vf)) |
---|
| 42 | return (eventer_func_t)vf; |
---|
43 | 43 | return (eventer_func_t)NULL; |
---|
44 | 44 | } |
---|
45 | 45 | const char *eventer_name_for_callback(eventer_func_t f) { |
---|
46 | 46 | const char *name; |
---|
47 | | if(noit_hash_retrieve(&__func_to_name, (char *)&f, sizeof(f), (void **)&name)) |
---|
| 47 | if(noit_hash_retr_str(&__func_to_name, (char *)&f, sizeof(f), &name)) |
---|
48 | 48 | return name; |
---|
49 | 49 | return NULL; |
---|
r11f8bf8 |
r6210da7 |
|
100 | 100 | if(!x509ctx) return 0; |
---|
101 | 101 | |
---|
102 | | if(!noit_hash_retrieve(options, "optional_no_ca", strlen("optional_no_ca"), |
---|
103 | | (void **)&opt_no_ca)) |
---|
| 102 | if(!noit_hash_retr_str(options, "optional_no_ca", strlen("optional_no_ca"), |
---|
| 103 | &opt_no_ca)) |
---|
104 | 104 | opt_no_ca = "false"; |
---|
105 | | if(!noit_hash_retrieve(options, "ignore_dates", strlen("ignore_dates"), |
---|
106 | | (void **)&ignore_dates)) |
---|
| 105 | if(!noit_hash_retr_str(options, "ignore_dates", strlen("ignore_dates"), |
---|
| 106 | &ignore_dates)) |
---|
107 | 107 | ignore_dates = "false"; |
---|
108 | 108 | |
---|
… | … | |
374 | 374 | eventer_SSL_read(int fd, void *buffer, size_t len, int *mask, void *closure) { |
---|
375 | 375 | int rv; |
---|
376 | | noitL(noit_debug, "SSL_read(%d) wants %ld bytes\n", fd, len); |
---|
| 376 | noitL(noit_debug, "SSL_read(%d) wants %ld bytes\n", fd, (long int)len); |
---|
377 | 377 | rv = eventer_SSL_rw(SSL_OP_READ, fd, buffer, len, mask, closure); |
---|
378 | | noitL(noit_debug, "SSL_read(%d) wanted %ld bytes, got return value %d\n", fd, len, rv); |
---|
| 378 | noitL(noit_debug, "SSL_read(%d) wanted %ld bytes, got return value %d\n", fd, (long int)len, rv); |
---|
379 | 379 | return rv; |
---|
380 | 380 | } |
---|
… | … | |
383 | 383 | void *closure) { |
---|
384 | 384 | int rv; |
---|
385 | | noitL(noit_debug, "SSL_write(%d) wants %ld bytes\n", fd, len); |
---|
| 385 | noitL(noit_debug, "SSL_write(%d) wants %ld bytes\n", fd, (long int)len); |
---|
386 | 386 | rv = eventer_SSL_rw(SSL_OP_WRITE, fd, (void *)buffer, len, mask, closure); |
---|
387 | | noitL(noit_debug, "SSL_write(%d) wanted %ld bytes, got return value %d\n", fd, len, rv); |
---|
| 387 | noitL(noit_debug, "SSL_write(%d) wanted %ld bytes, got return value %d\n", fd, (long int)len, rv); |
---|
388 | 388 | return rv; |
---|
389 | 389 | } |
---|
r84d6f13 |
r6210da7 |
|
288 | 288 | const char *key; |
---|
289 | 289 | int klen; |
---|
290 | | eventer_jobq_t *jobq; |
---|
| 290 | void *vjobq; |
---|
291 | 291 | noit_hash_iter iter = NOIT_HASH_ITER_ZERO; |
---|
292 | 292 | |
---|
293 | 293 | pthread_mutex_lock(&all_queues_lock); |
---|
294 | | while(noit_hash_next(&all_queues, &iter, &key, &klen, (void **)&jobq)) { |
---|
295 | | func(jobq, closure); |
---|
| 294 | while(noit_hash_next(&all_queues, &iter, &key, &klen, &vjobq)) { |
---|
| 295 | func((eventer_jobq_t *)vjobq, closure); |
---|
296 | 296 | } |
---|
297 | 297 | pthread_mutex_unlock(&all_queues_lock); |
---|
rdb656f3 |
r6210da7 |
|
48 | 48 | } |
---|
49 | 49 | static dns_ctx_handle_t *dns_ctx_alloc(const char *ns) { |
---|
| 50 | void *vh; |
---|
50 | 51 | dns_ctx_handle_t *h = NULL; |
---|
51 | 52 | pthread_mutex_lock(&dns_ctx_store_lock); |
---|
… | … | |
57 | 58 | } |
---|
58 | 59 | if(ns && |
---|
59 | | noit_hash_retrieve(&dns_ctx_store, ns, strlen(ns), (void **)&h)) { |
---|
| 60 | noit_hash_retrieve(&dns_ctx_store, ns, strlen(ns), &vh)) { |
---|
| 61 | h = (dns_ctx_handle_t *)vh; |
---|
60 | 62 | noit_atomic_inc32(&h->refcnt); |
---|
61 | 63 | } |
---|
… | … | |
130 | 132 | |
---|
131 | 133 | static int __isactive_ci(struct dns_check_info *ci) { |
---|
132 | | struct dns_check_info *u; |
---|
| 134 | void *u; |
---|
133 | 135 | int exists = 0; |
---|
134 | 136 | pthread_mutex_lock(&active_events_lock); |
---|
135 | | if(noit_hash_retrieve(&active_events, (void *)&ci, sizeof(ci), (void **)&u)) |
---|
| 137 | if(noit_hash_retrieve(&active_events, (void *)&ci, sizeof(ci), &u)) |
---|
136 | 138 | exists = 1; |
---|
137 | 139 | pthread_mutex_unlock(&active_events_lock); |
---|
… | … | |
498 | 500 | |
---|
499 | 501 | static int dns_check_send(noit_module_t *self, noit_check_t *check) { |
---|
| 502 | void *vnv_pair = NULL; |
---|
500 | 503 | struct dns_nameval *nv_pair; |
---|
501 | 504 | eventer_t newe; |
---|
… | … | |
534 | 537 | } |
---|
535 | 538 | #define CONFIG_OVERRIDE(a) \ |
---|
536 | | if(noit_hash_retrieve(check->config, #a, strlen(#a), \ |
---|
537 | | (void **)&config_val) && \ |
---|
| 539 | if(noit_hash_retr_str(check->config, #a, strlen(#a), \ |
---|
| 540 | &config_val) && \ |
---|
538 | 541 | strlen(config_val) > 0) \ |
---|
539 | 542 | a = config_val |
---|
… | … | |
586 | 589 | /* Lookup out class */ |
---|
587 | 590 | if(!noit_hash_retrieve(&dns_ctypes, ctype, strlen(ctype), |
---|
588 | | (void **)&nv_pair)) { |
---|
| 591 | &vnv_pair)) { |
---|
589 | 592 | ci->error = strdup("bad class"); |
---|
590 | 593 | } |
---|
591 | | else |
---|
| 594 | else { |
---|
| 595 | nv_pair = (struct dns_nameval *)vnv_pair; |
---|
592 | 596 | ci->query_ctype = nv_pair->val; |
---|
593 | | |
---|
| 597 | } |
---|
594 | 598 | /* Lookup out rr type */ |
---|
595 | 599 | if(!noit_hash_retrieve(&dns_rtypes, rtype, strlen(rtype), |
---|
596 | | (void **)&nv_pair)) { |
---|
| 600 | &vnv_pair)) { |
---|
597 | 601 | ci->error = strdup("bad rr type"); |
---|
598 | 602 | } |
---|
599 | | else |
---|
| 603 | else { |
---|
| 604 | nv_pair = (struct dns_nameval *)vnv_pair; |
---|
600 | 605 | ci->query_rtype = nv_pair->val; |
---|
| 606 | } |
---|
601 | 607 | |
---|
602 | 608 | if(!ci->error) { |
---|
r876ca61 |
r6210da7 |
|
202 | 202 | noit_check_t *check; |
---|
203 | 203 | struct check_info *ci; |
---|
| 204 | void *vci; |
---|
204 | 205 | |
---|
205 | 206 | if(!data->cr) { |
---|
… | … | |
278 | 279 | (const char *)&data->cr->check_no, |
---|
279 | 280 | sizeof(data->cr->check_no), |
---|
280 | | (void **)&ci) == 0) |
---|
281 | | ci = NULL; |
---|
| 281 | &vci) == 0) |
---|
| 282 | vci = NULL; |
---|
| 283 | ci = (struct check_info *)vci; |
---|
282 | 284 | |
---|
283 | 285 | /* We've seen it, it ain't coming again... |
---|
… | … | |
370 | 372 | const char *user = NULL, *group = NULL; |
---|
371 | 373 | if(data->options) { |
---|
372 | | noit_hash_retrieve(data->options, "user", 4, (void **)&user); |
---|
373 | | noit_hash_retrieve(data->options, "group", 4, (void **)&group); |
---|
| 374 | noit_hash_retr_str(data->options, "user", 4, &user); |
---|
| 375 | noit_hash_retr_str(data->options, "group", 4, &group); |
---|
374 | 376 | } |
---|
375 | 377 | noit_security_usergroup(user, group); |
---|
… | … | |
454 | 456 | ci->check = check; |
---|
455 | 457 | /* We might want to extract metrics */ |
---|
456 | | if(noit_hash_retrieve(check->config, |
---|
| 458 | if(noit_hash_retr_str(check->config, |
---|
457 | 459 | "output_extract", strlen("output_extract"), |
---|
458 | | (void **)&value) != 0) { |
---|
| 460 | &value) != 0) { |
---|
459 | 461 | const char *error; |
---|
460 | 462 | int erroffset; |
---|
… | … | |
473 | 475 | char argname[10]; |
---|
474 | 476 | snprintf(argname, sizeof(argname), "arg%d", i); |
---|
475 | | if(noit_hash_retrieve(check->config, argname, strlen(argname), |
---|
476 | | (void **)&value) == 0) break; |
---|
| 477 | if(noit_hash_retr_str(check->config, argname, strlen(argname), |
---|
| 478 | &value) == 0) break; |
---|
477 | 479 | i++; |
---|
478 | 480 | } |
---|
… | … | |
482 | 484 | |
---|
483 | 485 | /* Make the command */ |
---|
484 | | if(noit_hash_retrieve(check->config, "command", strlen("command"), |
---|
485 | | (void **)&value) == 0) { |
---|
| 486 | if(noit_hash_retr_str(check->config, "command", strlen("command"), |
---|
| 487 | &value) == 0) { |
---|
486 | 488 | value = "/bin/true"; |
---|
487 | 489 | } |
---|
… | … | |
493 | 495 | char argname[10]; |
---|
494 | 496 | snprintf(argname, sizeof(argname), "arg%d", i); |
---|
495 | | if(noit_hash_retrieve(check->config, argname, strlen(argname), |
---|
496 | | (void **)&value) == 0) { |
---|
| 497 | if(noit_hash_retr_str(check->config, argname, strlen(argname), |
---|
| 498 | &value) == 0) { |
---|
497 | 499 | if(i == 0) { |
---|
498 | 500 | /* if we don't have arg0, make it last element of path */ |
---|
… | … | |
513 | 515 | memset(&iter, 0, sizeof(iter)); |
---|
514 | 516 | ci->envcnt = 0; |
---|
515 | | while(noit_hash_next(check->config, &iter, &name, &klen, (void **)&value)) |
---|
| 517 | while(noit_hash_next_str(check->config, &iter, &name, &klen, &value)) |
---|
516 | 518 | if(!strncasecmp(name, "env_", 4)) |
---|
517 | 519 | ci->envcnt++; |
---|
… | … | |
520 | 522 | ci->envs = calloc(ci->envcnt, sizeof(*ci->envs)); |
---|
521 | 523 | ci->envcnt = 0; |
---|
522 | | while(noit_hash_next(check->config, &iter, &name, &klen, (void **)&value)) |
---|
| 524 | while(noit_hash_next_str(check->config, &iter, &name, &klen, &value)) |
---|
523 | 525 | if(!strncasecmp(name, "env_", 4)) { |
---|
524 | 526 | snprintf(interp_fmt, sizeof(interp_fmt), "%s=%s", name+4, value); |
---|
r4f91a9d |
r6210da7 |
|
557 | 557 | finish: |
---|
558 | 558 | gettimeofday(&ci->finish_time, NULL); |
---|
559 | | noitL(nldeb, "serf finished request (%s) [%d.%06d]\n", ctx->check->target, |
---|
560 | | ci->finish_time.tv_sec, ci->finish_time.tv_usec); |
---|
| 559 | noitL(nldeb, "serf finished request (%s) [%ld.%06d]\n", ctx->check->target, |
---|
| 560 | (long int)ci->finish_time.tv_sec, (int)ci->finish_time.tv_usec); |
---|
561 | 561 | if(ci->timeout_event) { |
---|
562 | 562 | eventer_remove(ci->timeout_event); |
---|
rdb656f3 |
r6210da7 |
|
35 | 35 | } |
---|
36 | 36 | static void |
---|
37 | | noit_lua_loader_set_directory(noit_module_loader_t *self, char *dir) { |
---|
| 37 | noit_lua_loader_set_directory(noit_module_loader_t *self, const char *dir) { |
---|
38 | 38 | struct loader_conf *c = __get_loader_conf(self); |
---|
39 | 39 | if(c->script_dir) free(c->script_dir); |
---|
… | … | |
59 | 59 | noit_lua_check_info_t * |
---|
60 | 60 | get_ci(lua_State *L) { |
---|
61 | | noit_lua_check_info_t *v = NULL; |
---|
62 | | if(noit_hash_retrieve(&noit_coros, (const char *)&L, sizeof(L), (void **)&v)) |
---|
63 | | return v; |
---|
| 61 | void *v = NULL; |
---|
| 62 | if(noit_hash_retrieve(&noit_coros, (const char *)&L, sizeof(L), &v)) |
---|
| 63 | return (noit_lua_check_info_t *)v; |
---|
64 | 64 | return NULL; |
---|
65 | 65 | } |
---|
… | … | |
136 | 136 | lua_createtable(L, 0, t ? t->size : 0); |
---|
137 | 137 | if(t) { |
---|
138 | | while(noit_hash_next(t, &iter, &key, &klen, (void **)&value)) { |
---|
| 138 | while(noit_hash_next_str(t, &iter, &key, &klen, &value)) { |
---|
139 | 139 | lua_pushlstring(L, value, strlen(value)); |
---|
140 | 140 | lua_setfield(L, -2, key); |
---|
… | … | |
776 | 776 | static int |
---|
777 | 777 | noit_lua_loader_config(noit_module_loader_t *self, noit_hash_table *o) { |
---|
778 | | char *dir = "."; |
---|
779 | | noit_hash_retrieve(o, "directory", strlen("directory"), (void **)&dir); |
---|
| 778 | const char *dir = "."; |
---|
| 779 | noit_hash_retr_str(o, "directory", strlen("directory"), &dir); |
---|
780 | 780 | noit_lua_loader_set_directory(self, dir); |
---|
781 | 781 | return 0; |
---|
rec240f3 |
r6210da7 |
|
382 | 382 | int interval = PING_INTERVAL; |
---|
383 | 383 | int count = PING_COUNT; |
---|
384 | | if(noit_hash_retrieve(check->config, "interval", strlen("interval"), |
---|
385 | | (void **)&config_val)) |
---|
| 384 | if(noit_hash_retr_str(check->config, "interval", strlen("interval"), |
---|
| 385 | &config_val)) |
---|
386 | 386 | interval = atoi(config_val); |
---|
387 | | if(noit_hash_retrieve(check->config, "count", strlen("count"), |
---|
388 | | (void **)&config_val)) |
---|
| 387 | if(noit_hash_retr_str(check->config, "count", strlen("count"), |
---|
| 388 | &config_val)) |
---|
389 | 389 | count = atoi(config_val); |
---|
390 | 390 | |
---|
rdb656f3 |
r6210da7 |
|
154 | 154 | |
---|
155 | 155 | #define FETCH_CONFIG_OR(key, str) do { \ |
---|
156 | | if(!noit_hash_retrieve(check->config, #key, strlen(#key), (void **)&key)) \ |
---|
| 156 | if(!noit_hash_retr_str(check->config, #key, strlen(#key), &key)) \ |
---|
157 | 157 | key = str; \ |
---|
158 | 158 | } while(0) |
---|
r84d6f13 |
r6210da7 |
|
87 | 87 | |
---|
88 | 88 | #define FETCH_CONFIG_OR(key, str) do { \ |
---|
89 | | if(!noit_hash_retrieve(check->config, #key, strlen(#key), (void **)&key)) \ |
---|
| 89 | if(!noit_hash_retr_str(check->config, #key, strlen(#key), &key)) \ |
---|
90 | 90 | key = str; \ |
---|
91 | 91 | } while(0) |
---|
r374e7c3 |
r6210da7 |
|
135 | 135 | } |
---|
136 | 136 | static struct check_info *get_check(int reqid) { |
---|
137 | | struct check_info *c; |
---|
138 | | if(noit_hash_retrieve(&active_checks, (char *)&reqid, sizeof(reqid), |
---|
139 | | (void **)&c)) |
---|
140 | | return c; |
---|
| 137 | void *vc; |
---|
| 138 | if(noit_hash_retrieve(&active_checks, (char *)&reqid, sizeof(reqid), &vc)) |
---|
| 139 | return (struct check_info *)vc; |
---|
141 | 140 | return NULL; |
---|
142 | 141 | } |
---|
… | … | |
148 | 147 | struct target_session * |
---|
149 | 148 | _get_target_session(noit_module_t *self, char *target) { |
---|
| 149 | void *vts; |
---|
150 | 150 | struct target_session *ts; |
---|
151 | 151 | snmp_mod_config_t *conf; |
---|
152 | 152 | conf = noit_module_get_userdata(self); |
---|
153 | 153 | if(!noit_hash_retrieve(&conf->target_sessions, |
---|
154 | | target, strlen(target), (void **)&ts)) { |
---|
| 154 | target, strlen(target), &vts)) { |
---|
155 | 155 | ts = calloc(1, sizeof(*ts)); |
---|
156 | 156 | ts->self = self; |
---|
… | … | |
160 | 160 | noit_hash_store(&conf->target_sessions, |
---|
161 | 161 | strdup(target), strlen(target), ts); |
---|
162 | | } |
---|
163 | | return ts; |
---|
| 162 | vts = ts; |
---|
| 163 | } |
---|
| 164 | return (struct target_session *)vts; |
---|
164 | 165 | } |
---|
165 | 166 | |
---|
… | … | |
687 | 688 | goto cleanup; |
---|
688 | 689 | } |
---|
689 | | if(!noit_hash_retrieve(check->config, "community", strlen("community"), |
---|
690 | | (void **)&community) && |
---|
691 | | !noit_hash_retrieve(conf->options, "community", strlen("community"), |
---|
692 | | (void **)&community)) { |
---|
| 690 | if(!noit_hash_retr_str(check->config, "community", strlen("community"), |
---|
| 691 | &community) && |
---|
| 692 | !noit_hash_retr_str(conf->options, "community", strlen("community"), |
---|
| 693 | &community)) { |
---|
693 | 694 | noitL(nlerr, "No community defined for check, dropping trap\n"); |
---|
694 | 695 | goto cleanup; |
---|
… | … | |
747 | 748 | sess.version = SNMP_VERSION_2c; |
---|
748 | 749 | sess.peername = check->target; |
---|
749 | | if(!noit_hash_retrieve(check->config, "community", strlen("community"), |
---|
750 | | (void **)&community)) { |
---|
| 750 | if(!noit_hash_retr_str(check->config, "community", strlen("community"), |
---|
| 751 | &community)) { |
---|
751 | 752 | community = "public"; |
---|
752 | 753 | } |
---|
… | … | |
777 | 778 | |
---|
778 | 779 | /* Figure our how many. */ |
---|
779 | | while(noit_hash_next(check->config, &iter, &name, &klen, (void **)&value)) { |
---|
| 780 | while(noit_hash_next_str(check->config, &iter, &name, &klen, &value)) { |
---|
780 | 781 | if(!strncasecmp(name, "oid_", 4)) { |
---|
781 | 782 | info->noids++; |
---|
… | … | |
792 | 793 | memset(&iter, 0, sizeof(iter)); |
---|
793 | 794 | i = 0; |
---|
794 | | while(noit_hash_next(check->config, &iter, &name, &klen, (void **)&value)) { |
---|
| 795 | while(noit_hash_next_str(check->config, &iter, &name, &klen, &value)) { |
---|
795 | 796 | if(!strncasecmp(name, "oid_", 4)) { |
---|
796 | 797 | char oidbuff[128]; |
---|
rdb656f3 |
r6210da7 |
|
202 | 202 | socklen_t sockaddr_len; |
---|
203 | 203 | unsigned short ssh_port = DEFAULT_SSH_PORT; |
---|
204 | | const char *port_str; |
---|
| 204 | const char *port_str = NULL; |
---|
205 | 205 | long on; |
---|
206 | 206 | |
---|
… | … | |
230 | 230 | if(ioctl(fd, FIONBIO, &on)) goto fail; |
---|
231 | 231 | |
---|
232 | | if(noit_hash_retrieve(check->config, "port", strlen("port"), |
---|
233 | | (void **)&port_str)) { |
---|
| 232 | if(noit_hash_retr_str(check->config, "port", strlen("port"), |
---|
| 233 | &port_str)) { |
---|
234 | 234 | ssh_port = (unsigned short)atoi(port_str); |
---|
235 | 235 | } |
---|
r5b175f1 |
r6210da7 |
|
107 | 107 | sec = noit_conf_get_sections(NULL, xpath, &cnt); |
---|
108 | 108 | for(i=0; i<cnt; i++) { |
---|
109 | | noit_check_t *existing_check; |
---|
| 109 | void *vcheck; |
---|
110 | 110 | char uuid_str[37]; |
---|
111 | 111 | char target[256]; |
---|
… | … | |
183 | 183 | |
---|
184 | 184 | if(noit_hash_retrieve(&polls, (char *)uuid, UUID_SIZE, |
---|
185 | | (void **)&existing_check)) { |
---|
| 185 | &vcheck)) { |
---|
| 186 | noit_check_t *existing_check = (noit_check_t *)vcheck; |
---|
186 | 187 | /* Once set, we can never change it. */ |
---|
187 | 188 | assert(!existing_check->module || !existing_check->module[0] || |
---|
… | … | |
238 | 239 | uuid_t key_id; |
---|
239 | 240 | int klen; |
---|
240 | | noit_check_t *check; |
---|
| 241 | void *vcheck; |
---|
241 | 242 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
242 | | (void **)&check)) { |
---|
243 | | noit_check_activate(check); |
---|
| 243 | &vcheck)) { |
---|
| 244 | noit_check_activate((noit_check_t *)vcheck); |
---|
244 | 245 | } |
---|
245 | 246 | } |
---|
… | … | |
250 | 251 | uuid_t key_id; |
---|
251 | 252 | int klen; |
---|
252 | | noit_check_t *check, *tofree = NULL; |
---|
| 253 | noit_check_t *tofree = NULL; |
---|
| 254 | void *vcheck; |
---|
253 | 255 | |
---|
254 | 256 | /* Cleanup any previous causal map */ |
---|
255 | 257 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
256 | | (void **)&check)) { |
---|
| 258 | &vcheck)) { |
---|
| 259 | noit_check_t *check = (noit_check_t *)vcheck; |
---|
257 | 260 | /* We don't free the one we're looking at... we free it on the next |
---|
258 | 261 | * pass. This leaves out iterator in good shape. We just need to |
---|
… | … | |
276 | 279 | uuid_t key_id; |
---|
277 | 280 | int klen; |
---|
278 | | noit_check_t *check, *parent; |
---|
| 281 | void *vcheck; |
---|
279 | 282 | |
---|
280 | 283 | /* Cleanup any previous causal map */ |
---|
281 | 284 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
282 | | (void **)&check)) { |
---|
| 285 | &vcheck)) { |
---|
| 286 | noit_check_t *check = (noit_check_t *)vcheck; |
---|
283 | 287 | dep_list_t *dep; |
---|
284 | 288 | while((dep = check->causal_checks) != NULL) { |
---|
… | … | |
291 | 295 | /* Walk all checks and add check dependencies to their parents */ |
---|
292 | 296 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
293 | | (void **)&check)) { |
---|
| 297 | &vcheck)) { |
---|
| 298 | noit_check_t *check = (noit_check_t *)vcheck, *parent; |
---|
294 | 299 | if(check->oncheck) { |
---|
295 | 300 | /* This service is causally triggered by another service */ |
---|
… | … | |
361 | 366 | noit_check_clone(uuid_t in) { |
---|
362 | 367 | noit_check_t *checker, *new_check; |
---|
| 368 | void *vcheck; |
---|
363 | 369 | if(noit_hash_retrieve(&polls, |
---|
364 | 370 | (char *)in, UUID_SIZE, |
---|
365 | | (void **)&checker) == 0) { |
---|
| 371 | &vcheck) == 0) { |
---|
366 | 372 | return NULL; |
---|
367 | 373 | } |
---|
| 374 | checker = (noit_check_t *)vcheck; |
---|
368 | 375 | if(checker->oncheck) { |
---|
369 | 376 | return NULL; |
---|
… | … | |
562 | 569 | int |
---|
563 | 570 | noit_poller_deschedule(uuid_t in) { |
---|
| 571 | void *vcheck; |
---|
564 | 572 | noit_check_t *checker; |
---|
565 | 573 | noit_module_t *mod; |
---|
566 | 574 | if(noit_hash_retrieve(&polls, |
---|
567 | 575 | (char *)in, UUID_SIZE, |
---|
568 | | (void **)&checker) == 0) { |
---|
| 576 | &vcheck) == 0) { |
---|
569 | 577 | return -1; |
---|
570 | 578 | } |
---|
| 579 | checker = (noit_check_t *)vcheck; |
---|
571 | 580 | checker->flags |= (NP_DISABLED|NP_KILLED); |
---|
572 | 581 | |
---|
… | … | |
601 | 610 | noit_check_t * |
---|
602 | 611 | noit_poller_lookup(uuid_t in) { |
---|
603 | | noit_check_t *check; |
---|
604 | | if(noit_hash_retrieve(&polls, |
---|
605 | | (char *)in, UUID_SIZE, |
---|
606 | | (void **)&check)) { |
---|
607 | | return check; |
---|
608 | | } |
---|
| 612 | void *vcheck; |
---|
| 613 | if(noit_hash_retrieve(&polls, (char *)in, UUID_SIZE, &vcheck)) |
---|
| 614 | return (noit_check_t *)vcheck; |
---|
609 | 615 | return NULL; |
---|
610 | 616 | } |
---|
… | … | |
869 | 875 | uuid_t key_id; |
---|
870 | 876 | int klen, i = 0; |
---|
871 | | noit_check_t *check; |
---|
| 877 | void *vcheck; |
---|
872 | 878 | |
---|
873 | 879 | if(argc == 1) { |
---|
… | … | |
877 | 883 | } |
---|
878 | 884 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
879 | | (void **)&check)) { |
---|
| 885 | &vcheck)) { |
---|
| 886 | noit_check_t *check = (noit_check_t *)vcheck; |
---|
880 | 887 | char out[512]; |
---|
881 | 888 | char uuid_str[37]; |
---|
… | … | |
910 | 917 | uuid_t key_id; |
---|
911 | 918 | int klen, i = 0; |
---|
912 | | noit_check_t *check; |
---|
913 | 919 | |
---|
914 | 920 | if(argc == 1) { |
---|
| 921 | void *vcheck; |
---|
915 | 922 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
916 | | (void **)&check)) { |
---|
| 923 | &vcheck)) { |
---|
917 | 924 | char out[512]; |
---|
918 | 925 | char uuid_str[37]; |
---|
| 926 | noit_check_t *check = (noit_check_t *)vcheck; |
---|
919 | 927 | snprintf(out, sizeof(out), "%s`%s", check->target, check->name); |
---|
920 | 928 | uuid_unparse_lower(check->checkid, uuid_str); |
---|
… | … | |
940 | 948 | noit_console_state_t *dstate, |
---|
941 | 949 | void *closure) { |
---|
942 | | struct timeval _now; |
---|
943 | 950 | noit_hash_iter iter = NOIT_HASH_ITER_ZERO; |
---|
944 | 951 | uuid_t key_id; |
---|
945 | 952 | int klen; |
---|
946 | | noit_check_t *check; |
---|
947 | | |
---|
948 | | gettimeofday(&_now, NULL); |
---|
| 953 | void *vcheck; |
---|
| 954 | |
---|
949 | 955 | while(noit_hash_next(&polls, &iter, (const char **)key_id, &klen, |
---|
950 | | (void **)&check)) { |
---|
951 | | nc_printf_check_brief(ncct, check); |
---|
| 956 | &vcheck)) { |
---|
| 957 | nc_printf_check_brief(ncct, (noit_check_t *)vcheck); |
---|
952 | 958 | } |
---|
953 | 959 | return 0; |
---|
rb13e0b2 |
r6210da7 |
|
113 | 113 | const char *key; |
---|
114 | 114 | int klen; |
---|
115 | | metric_t *m; |
---|
116 | 115 | stats_t *c; |
---|
| 116 | void *vm; |
---|
117 | 117 | |
---|
118 | 118 | uuid_unparse_lower(check->checkid, uuid_str); |
---|
119 | 119 | c = &check->stats.current; |
---|
120 | | while(noit_hash_next(&c->metrics, &iter, &key, &klen, (void **)&m)) { |
---|
| 120 | while(noit_hash_next(&c->metrics, &iter, &key, &klen, &vm)) { |
---|
121 | 121 | /* If we apply the filter set and it returns false, we don't log */ |
---|
| 122 | metric_t *m = (metric_t *)vm; |
---|
122 | 123 | if(!noit_apply_filterset(check->filterset, check, m)) continue; |
---|
123 | 124 | if(!ls->enabled) continue; |
---|
r5a9b91b |
r6210da7 |
|
65 | 65 | if(*oper == ':' && |
---|
66 | 66 | (nkey = strnstrn(":", 1, oper + 1, fmte - key - 1)) != NULL) { |
---|
| 67 | void *voper; |
---|
67 | 68 | oper++; |
---|
68 | 69 | /* find oper, nkey-oper */ |
---|
69 | 70 | if(!noit_hash_retrieve(&interpolation_operators, |
---|
70 | 71 | oper, nkey - oper, |
---|
71 | | (void **)&oper_sprint)) { |
---|
| 72 | &voper)) { |
---|
72 | 73 | /* else oper <- copy */ |
---|
73 | 74 | oper_sprint = interpolate_oper_copy; |
---|
74 | 75 | } |
---|
| 76 | else |
---|
| 77 | oper_sprint = voper; |
---|
75 | 78 | nkey++; |
---|
76 | 79 | } |
---|
… | … | |
79 | 82 | nkey = key; |
---|
80 | 83 | } |
---|
81 | | if(!noit_hash_retrieve((closer == '}') ? config : attrs, |
---|
82 | | nkey, fmte - nkey, (void **)&replacement)) |
---|
| 84 | if(!noit_hash_retr_str((closer == '}') ? config : attrs, |
---|
| 85 | nkey, fmte - nkey, &replacement)) |
---|
83 | 86 | replacement = ""; |
---|
84 | 87 | fmt = fmte + 1; /* Format points just after the end of the key */ |
---|
rc8af4b3 |
r6210da7 |
|
313 | 313 | int _noit_conf_get_string(noit_conf_section_t section, xmlNodePtr *vnode, |
---|
314 | 314 | const char *path, char **value) { |
---|
315 | | char *str; |
---|
| 315 | const char *str; |
---|
316 | 316 | int i, rv = 1; |
---|
317 | 317 | xmlXPathObjectPtr pobj = NULL; |
---|
… | … | |
341 | 341 | } |
---|
342 | 342 | fallback: |
---|
343 | | if(noit_hash_retrieve(&_compiled_fallback, |
---|
344 | | path, strlen(path), (void **)&str)) { |
---|
| 343 | if(noit_hash_retr_str(&_compiled_fallback, |
---|
| 344 | path, strlen(path), &str)) { |
---|
345 | 345 | *value = (char *)xmlStrdup((xmlChar *)str); |
---|
346 | 346 | goto found; |
---|
r31eed12 |
r6210da7 |
|
163 | 163 | |
---|
164 | 164 | for(i=0; i<argc; i+=2) { |
---|
| 165 | void *vattrinfo; |
---|
165 | 166 | struct _valid_attr_t *attrinfo; |
---|
166 | 167 | char *attr = argv[i], *val = NULL; |
---|
… | … | |
168 | 169 | else val = argv[i+1]; |
---|
169 | 170 | if(!noit_hash_retrieve(&check_attrs, attr, strlen(attr), |
---|
170 | | (void **)&attrinfo)) { |
---|
| 171 | &vattrinfo)) { |
---|
171 | 172 | error = 1; |
---|
172 | 173 | break; |
---|
173 | 174 | } |
---|
| 175 | attrinfo = vattrinfo; |
---|
174 | 176 | /* The fixation stuff doesn't matter here, this check is brand-new */ |
---|
175 | 177 | xmlUnsetProp(node, (xmlChar *)attrinfo->name); |
---|
r87de1cf |
r6210da7 |
|
58 | 58 | #undef HAVE_DIRENT_H |
---|
59 | 59 | #undef HAVE_PWD_H |
---|
| 60 | #undef HAVE_PTY_H |
---|
60 | 61 | #undef HAVE_ERRNO_H |
---|
61 | 62 | #undef HAVE_STRING_H |
---|
r680ff24 |
r6210da7 |
|
24 | 24 | #ifdef HAVE_TERMIOS_H |
---|
25 | 25 | #include <termios.h> |
---|
| 26 | #endif |
---|
| 27 | #ifdef HAVE_PTY_H |
---|
| 28 | #include <pty.h> |
---|
26 | 29 | #endif |
---|
27 | 30 | #ifdef HAVE_UTIL_H |
---|
… | … | |
209 | 212 | noit_console_userdata_get(struct __noit_console_closure *ncct, |
---|
210 | 213 | const char *name) { |
---|
211 | | noit_console_userdata_t *item; |
---|
| 214 | void *vitem; |
---|
212 | 215 | if(noit_hash_retrieve(&ncct->userdata, name, strlen(name), |
---|
213 | | (void **)&item)) |
---|
214 | | return item->data; |
---|
| 216 | &vitem)) |
---|
| 217 | return ((noit_console_userdata_t *)vitem)->data; |
---|
215 | 218 | return NULL; |
---|
216 | 219 | } |
---|
… | … | |
361 | 364 | } |
---|
362 | 365 | |
---|
363 | | if(!noit_hash_retrieve(ac->config, |
---|
| 366 | if(!noit_hash_retr_str(ac->config, |
---|
364 | 367 | "line_protocol", strlen("line_protocol"), |
---|
365 | | (void **)&line_protocol)) { |
---|
| 368 | &line_protocol)) { |
---|
366 | 369 | line_protocol = NULL; |
---|
367 | 370 | } |
---|
r057e0c6 |
r6210da7 |
|
157 | 157 | * a filterset other than check->filterset.. You never know. |
---|
158 | 158 | */ |
---|
159 | | filterset_t *fs; |
---|
| 159 | void *vfs; |
---|
160 | 160 | if(!filtersets || !filterset) return noit_true; |
---|
161 | 161 | |
---|
162 | | if(noit_hash_retrieve(filtersets, filterset, strlen(filterset), |
---|
163 | | (void **)&fs)) { |
---|
| 162 | if(noit_hash_retrieve(filtersets, filterset, strlen(filterset), &vfs)) { |
---|
| 163 | filterset_t *fs = (filterset_t *)vfs; |
---|
164 | 164 | filterrule_t *r; |
---|
165 | 165 | #define MATCHES(rname, value) noit_apply_filterrule(r->rname, r->rname##_e, value) |
---|
r26e5e98 |
r6210da7 |
|
298 | 298 | const char *prefix = NULL; |
---|
299 | 299 | int l1, l2; |
---|
300 | | noit_hash_retrieve(&req->headers, last_name, strlen(last_name), |
---|
301 | | (void **)&prefix); |
---|
| 300 | noit_hash_retr_str(&req->headers, last_name, strlen(last_name), |
---|
| 301 | &prefix); |
---|
302 | 302 | if(!prefix) FAIL; |
---|
303 | 303 | l1 = strlen(prefix); |
---|
… | … | |
583 | 583 | b->size += slen; \ |
---|
584 | 584 | } while(0) |
---|
585 | | while(noit_hash_next(&ctx->res.headers, &iter, |
---|
586 | | &key, &klen, (void **)&value)) { |
---|
| 585 | while(noit_hash_next_str(&ctx->res.headers, &iter, |
---|
| 586 | &key, &klen, &value)) { |
---|
587 | 587 | int vlen = strlen(value); |
---|
588 | 588 | CTX_LEADER_APPEND(key, klen); |
---|
r6bb9ef8 |
r6210da7 |
|
186 | 186 | char path[PATH_MAX], *sub; |
---|
187 | 187 | jcl = ac->service_ctx = noit_jlog_closure_alloc(); |
---|
188 | | if(!noit_hash_retrieve(ac->config, |
---|
| 188 | if(!noit_hash_retr_str(ac->config, |
---|
189 | 189 | "log_transit_feed_name", |
---|
190 | 190 | strlen("log_transit_feed_name"), |
---|
191 | | (void **)&logname)) { |
---|
| 191 | &logname)) { |
---|
192 | 192 | noitL(noit_error, "No 'log_transit_feed_name' specified in log_transit.\n"); |
---|
193 | 193 | goto socket_error; |
---|
r50d9d44 |
r6210da7 |
|
102 | 102 | |
---|
103 | 103 | if(listener_closure->sslconfig->size) { |
---|
104 | | char *cert, *key, *ca, *ciphers; |
---|
| 104 | const char *cert, *key, *ca, *ciphers; |
---|
105 | 105 | eventer_ssl_ctx_t *ctx; |
---|
106 | 106 | /* We have an SSL configuration. While our socket accept is |
---|
… | … | |
109 | 109 | */ |
---|
110 | 110 | #define SSLCONFGET(var,name) do { \ |
---|
111 | | if(!noit_hash_retrieve(listener_closure->sslconfig, name, strlen(name), \ |
---|
112 | | (void **)&var)) var = NULL; } while(0) |
---|
| 111 | if(!noit_hash_retr_str(listener_closure->sslconfig, name, strlen(name), \ |
---|
| 112 | &var)) var = NULL; } while(0) |
---|
113 | 113 | SSLCONFGET(cert, "certificate_file"); |
---|
114 | 114 | SSLCONFGET(key, "key_file"); |
---|
… | … | |
345 | 345 | u_int32_t cmd; |
---|
346 | 346 | int len; |
---|
347 | | noit_hash_table *delegation_table; |
---|
| 347 | void *vdelegation_table; |
---|
| 348 | noit_hash_table *delegation_table = NULL; |
---|
348 | 349 | acceptor_closure_t *ac = closure; |
---|
349 | 350 | |
---|
… | … | |
367 | 368 | if(noit_hash_retrieve(&listener_commands, |
---|
368 | 369 | (char *)&ac->dispatch, sizeof(ac->dispatch), |
---|
369 | | (void **)&delegation_table)) { |
---|
370 | | eventer_func_t *eventer_func; |
---|
| 370 | (void **)&vdelegation_table)) { |
---|
| 371 | void *vfunc; |
---|
| 372 | delegation_table = (noit_hash_table *)vdelegation_table; |
---|
371 | 373 | if(noit_hash_retrieve(delegation_table, |
---|
372 | | (char *)&cmd, sizeof(cmd), |
---|
373 | | (void **)&eventer_func)) { |
---|
374 | | e->callback = *eventer_func; |
---|
| 374 | (char *)&cmd, sizeof(cmd), &vfunc)) { |
---|
| 375 | e->callback = *((eventer_func_t *)vfunc); |
---|
375 | 376 | return e->callback(e, mask, closure, now); |
---|
376 | 377 | } |
---|
… | … | |
396 | 397 | u_int32_t *cmd_copy; |
---|
397 | 398 | eventer_func_t *handler_copy; |
---|
| 399 | void *vdelegation_table; |
---|
398 | 400 | noit_hash_table *delegation_table; |
---|
399 | 401 | if(!noit_hash_retrieve(&listener_commands, |
---|
400 | 402 | (char *)&listener_dispatch, sizeof(listener_dispatch), |
---|
401 | | (void **)&delegation_table)) { |
---|
| 403 | &vdelegation_table)) { |
---|
402 | 404 | delegation_table = calloc(1, sizeof(*delegation_table)); |
---|
403 | 405 | handler_copy = malloc(sizeof(*handler_copy)); |
---|
… | … | |
407 | 409 | delegation_table); |
---|
408 | 410 | } |
---|
| 411 | else |
---|
| 412 | delegation_table = (noit_hash_table *)vdelegation_table; |
---|
| 413 | |
---|
409 | 414 | cmd_copy = malloc(sizeof(*cmd_copy)); |
---|
410 | 415 | *cmd_copy = cmd; |
---|
r56c7e9d |
r6210da7 |
|
44 | 44 | |
---|
45 | 45 | noit_module_loader_t * noit_loader_lookup(const char *name) { |
---|
46 | | noit_module_loader_t *loader; |
---|
47 | | |
---|
48 | | if(noit_hash_retrieve(&loaders, name, strlen(name), (void **)&loader)) { |
---|
49 | | return loader; |
---|
50 | | } |
---|
| 46 | void *vloader; |
---|
| 47 | |
---|
| 48 | if(noit_hash_retrieve(&loaders, name, strlen(name), &vloader)) |
---|
| 49 | return (noit_module_loader_t *)vloader; |
---|
51 | 50 | return NULL; |
---|
52 | 51 | } |
---|
53 | 52 | |
---|
54 | 53 | noit_module_t * noit_module_lookup(const char *name) { |
---|
55 | | noit_module_t *module; |
---|
56 | | |
---|
57 | | if(noit_hash_retrieve(&modules, name, strlen(name), (void **)&module)) { |
---|
58 | | return module; |
---|
59 | | } |
---|
| 54 | void *vmodule; |
---|
| 55 | |
---|
| 56 | if(noit_hash_retrieve(&modules, name, strlen(name), &vmodule)) |
---|
| 57 | return (noit_module_t *)vmodule; |
---|
60 | 58 | return NULL; |
---|
61 | 59 | } |
---|
… | … | |
249 | 247 | const char *name; |
---|
250 | 248 | int klen, i = 0; |
---|
251 | | noit_image_t *hdr; |
---|
| 249 | void *vhdr; |
---|
252 | 250 | |
---|
253 | 251 | while(noit_hash_next(&loaders, &iter, (const char **)&name, &klen, |
---|
254 | | (void **)&hdr)) { |
---|
| 252 | &vhdr)) { |
---|
| 253 | noit_image_t *hdr = (noit_image_t *)vhdr; |
---|
255 | 254 | if(!strncmp(hdr->name, argv[0], strlen(argv[0]))) { |
---|
256 | 255 | if(idx == i) return strdup(hdr->name); |
---|
… | … | |
260 | 259 | memset(&iter, 0, sizeof(iter)); |
---|
261 | 260 | while(noit_hash_next(&modules, &iter, (const char **)&name, &klen, |
---|
262 | | (void **)&hdr)) { |
---|
| 261 | &vhdr)) { |
---|
| 262 | noit_image_t *hdr = (noit_image_t *)vhdr; |
---|
263 | 263 | if(!strncmp(hdr->name, argv[0], strlen(argv[0]))) { |
---|
264 | 264 | if(idx == i) return strdup(hdr->name); |
---|
… | … | |
283 | 283 | const char *name; |
---|
284 | 284 | int klen; |
---|
285 | | noit_image_t *hdr; |
---|
| 285 | void *vhdr; |
---|
286 | 286 | |
---|
287 | 287 | nc_printf(ncct, "= Loaders and Modules =\n"); |
---|
288 | 288 | while(noit_hash_next(&loaders, &iter, (const char **)&name, &klen, |
---|
289 | | (void **)&hdr)) { |
---|
| 289 | &vhdr)) { |
---|
| 290 | noit_image_t *hdr = (noit_image_t *)vhdr;; |
---|
290 | 291 | nc_printf(ncct, " %s\n", hdr->name); |
---|
291 | 292 | } |
---|
292 | 293 | memset(&iter, 0, sizeof(iter)); |
---|
293 | 294 | while(noit_hash_next(&modules, &iter, (const char **)&name, &klen, |
---|
294 | | (void **)&hdr)) { |
---|
| 295 | &vhdr)) { |
---|
| 296 | noit_image_t *hdr = (noit_image_t *)vhdr;; |
---|
295 | 297 | nc_printf(ncct, " %s\n", hdr->name); |
---|
296 | 298 | } |
---|
r1d69a01 |
r6210da7 |
|
1 | | /* Generated by re2c 0.12.0 on Fri Feb 8 14:52:45 2008 */ |
---|
| 1 | /* Generated by re2c 0.13.2 on Tue Mar 17 15:37:18 2009 */ |
---|
2 | 2 | #line 1 "noit_tokenizer.re" |
---|
| 3 | #include "noit_defines.h" |
---|
3 | 4 | #include <stdlib.h> |
---|
4 | 5 | #include <string.h> |
---|
… | … | |
47 | 48 | mainpattern: |
---|
48 | 49 | |
---|
49 | | #line 50 "noit_tokenizer.c" |
---|
| 50 | #line 51 "noit_tokenizer.c" |
---|
50 | 51 | { |
---|
51 | 52 | unsigned char yych; |
---|
52 | 53 | |
---|
53 | 54 | yych = (unsigned char)*t->next; |
---|
54 | | switch(yych) { |
---|
| 55 | switch (yych) { |
---|
55 | 56 | case 0x00: goto yy10; |
---|
56 | 57 | case 0x09: |
---|
… | … | |
67 | 68 | goto yy17; |
---|
68 | 69 | yy3: |
---|
69 | | #line 53 "noit_tokenizer.re" |
---|
| 70 | #line 54 "noit_tokenizer.re" |
---|
70 | 71 | { t->token = NULL; |
---|
71 | 72 | t->end = t->next; |
---|
72 | 73 | t->type = NT_SPACE; |
---|
73 | 74 | return 1; } |
---|
74 | | #line 75 "noit_tokenizer.c" |
---|
| 75 | #line 76 "noit_tokenizer.c" |
---|
75 | 76 | yy4: |
---|
76 | 77 | ++t->next; |
---|
77 | | #line 57 "noit_tokenizer.re" |
---|
| 78 | #line 58 "noit_tokenizer.re" |
---|
78 | 79 | { t->type = NT_DQSTRING; |
---|
79 | 80 | if(t->start != t->end) { |
---|
… | … | |
88 | 89 | goto dqstring; |
---|
89 | 90 | } |
---|
90 | | #line 91 "noit_tokenizer.c" |
---|
| 91 | #line 92 "noit_tokenizer.c" |
---|
91 | 92 | yy6: |
---|
92 | 93 | ++t->next; |
---|
93 | | #line 69 "noit_tokenizer.re" |
---|
| 94 | #line 70 "noit_tokenizer.re" |
---|
94 | 95 | { t->type = NT_IDENT; |
---|
95 | 96 | if(t->start != t->end) { |
---|
… | … | |
103 | 104 | goto sqstring; |
---|
104 | 105 | } |
---|
105 | | #line 106 "noit_tokenizer.c" |
---|
| 106 | #line 107 "noit_tokenizer.c" |
---|
106 | 107 | yy8: |
---|
107 | 108 | ++t->next; |
---|
… | … | |
109 | 110 | goto yy13; |
---|
110 | 111 | yy9: |
---|
111 | | #line 81 "noit_tokenizer.re" |
---|
| 112 | #line 82 "noit_tokenizer.re" |
---|
112 | 113 | { char only = ' '; |
---|
113 | 114 | t->end = t->next; |
---|
… | … | |
118 | 119 | return 1; |
---|
119 | 120 | } |
---|
120 | | #line 121 "noit_tokenizer.c" |
---|
| 121 | #line 122 "noit_tokenizer.c" |
---|
121 | 122 | yy10: |
---|
122 | 123 | ++t->next; |
---|
123 | | #line 89 "noit_tokenizer.re" |
---|
| 124 | #line 90 "noit_tokenizer.re" |
---|
124 | 125 | { t->token = NULL; |
---|
125 | 126 | t->type = NT_EOF; |
---|
126 | 127 | return 0; |
---|
127 | 128 | } |
---|
128 | | #line 129 "noit_tokenizer.c" |
---|
| 129 | #line 130 "noit_tokenizer.c" |
---|
129 | 130 | yy12: |
---|
130 | 131 | ++t->next; |
---|
131 | 132 | yych = (unsigned char)*t->next; |
---|
132 | 133 | yy13: |
---|
133 | | switch(yych) { |
---|
| 134 | switch (yych) { |
---|
134 | 135 | case 0x00: |
---|
135 | 136 | case 0x09: |
---|
… | … | |
143 | 144 | ++t->next; |
---|
144 | 145 | yych = (unsigned char)*t->next; |
---|
145 | | switch(yych) { |
---|
| 146 | switch (yych) { |
---|
146 | 147 | case 0x00: |
---|
147 | 148 | case 0x09: |
---|
… | … | |
155 | 156 | yych = (unsigned char)*t->next; |
---|
156 | 157 | yy17: |
---|
157 | | switch(yych) { |
---|
| 158 | switch (yych) { |
---|
158 | 159 | case 0x09: |
---|
159 | 160 | case 0x0A: |
---|
… | … | |
163 | 164 | } |
---|
164 | 165 | } |
---|
165 | | #line 94 "noit_tokenizer.re" |
---|
| 166 | #line 95 "noit_tokenizer.re" |
---|
166 | 167 | |
---|
167 | 168 | |
---|
168 | 169 | sqstring: |
---|
169 | 170 | |
---|
170 | | #line 171 "noit_tokenizer.c" |
---|
| 171 | #line 172 "noit_tokenizer.c" |
---|
171 | 172 | { |
---|
172 | 173 | unsigned char yych; |
---|
173 | 174 | yych = (unsigned char)*t->next; |
---|
174 | | switch(yych) { |
---|
| 175 | switch (yych) { |
---|
175 | 176 | case 0x00: goto yy23; |
---|
176 | 177 | case '\'': goto yy20; |
---|
… | … | |
178 | 179 | } |
---|
179 | 180 | yy20: |
---|
180 | | #line 98 "noit_tokenizer.re" |
---|
| 181 | #line 99 "noit_tokenizer.re" |
---|
181 | 182 | { t->end = t->next; |
---|
182 | 183 | goto mainpattern; } |
---|
183 | | #line 184 "noit_tokenizer.c" |
---|
| 184 | #line 185 "noit_tokenizer.c" |
---|
184 | 185 | yy21: |
---|
185 | 186 | ++t->next; |
---|
186 | 187 | yych = (unsigned char)*t->next; |
---|
187 | | switch(yych) { |
---|
| 188 | switch (yych) { |
---|
188 | 189 | case 0x00: |
---|
189 | 190 | case '\'': goto yy20; |
---|
… | … | |
192 | 193 | yy23: |
---|
193 | 194 | ++t->next; |
---|
194 | | #line 100 "noit_tokenizer.re" |
---|
| 195 | #line 101 "noit_tokenizer.re" |
---|
195 | 196 | { BAIL_UNKNOWN; } |
---|
196 | | #line 197 "noit_tokenizer.c" |
---|
| 197 | #line 198 "noit_tokenizer.c" |
---|
197 | 198 | } |
---|
198 | | #line 101 "noit_tokenizer.re" |
---|
| 199 | #line 102 "noit_tokenizer.re" |
---|
199 | 200 | |
---|
200 | 201 | |
---|
201 | 202 | dqstring: |
---|
202 | 203 | |
---|
203 | | #line 204 "noit_tokenizer.c" |
---|
| 204 | #line 205 "noit_tokenizer.c" |
---|
204 | 205 | { |
---|
205 | 206 | unsigned char yych; |
---|
206 | 207 | yych = (unsigned char)*t->next; |
---|
207 | | switch(yych) { |
---|
| 208 | switch (yych) { |
---|
208 | 209 | case 0x00: goto yy33; |
---|
209 | 210 | case '"': goto yy29; |
---|
… | … | |
213 | 214 | yy27: |
---|
214 | 215 | yych = (unsigned char)*++t->next; |
---|
215 | | switch(yych) { |
---|
| 216 | switch (yych) { |
---|
216 | 217 | case 0x00: goto yy28; |
---|
217 | 218 | case '"': |
---|
… | … | |
230 | 231 | yy29: |
---|
231 | 232 | ++t->next; |
---|
232 | | #line 109 "noit_tokenizer.re" |
---|
| 233 | #line 110 "noit_tokenizer.re" |
---|
233 | 234 | { t->end = t->next--; |
---|
234 | 235 | goto mainpattern; |
---|
235 | 236 | } |
---|
236 | | #line 237 "noit_tokenizer.c" |
---|
| 237 | #line 238 "noit_tokenizer.c" |
---|
237 | 238 | yy31: |
---|
238 | 239 | ++t->next; |
---|
239 | | #line 112 "noit_tokenizer.re" |
---|
| 240 | #line 113 "noit_tokenizer.re" |
---|
240 | 241 | { goto dqstring; } |
---|
241 | | #line 242 "noit_tokenizer.c" |
---|
| 242 | #line 243 "noit_tokenizer.c" |
---|
242 | 243 | yy33: |
---|
243 | 244 | ++t->next; |
---|
244 | | #line 113 "noit_tokenizer.re" |
---|
| 245 | #line 114 "noit_tokenizer.re" |
---|
245 | 246 | { BAIL_UNKNOWN; } |
---|
246 | | #line 247 "noit_tokenizer.c" |
---|
| 247 | #line 248 "noit_tokenizer.c" |
---|
247 | 248 | yy35: |
---|
248 | 249 | ++t->next; |
---|
249 | | #line 108 "noit_tokenizer.re" |
---|
| 250 | #line 109 "noit_tokenizer.re" |
---|
250 | 251 | { goto dqstring; } |
---|
251 | | #line 252 "noit_tokenizer.c" |
---|
| 252 | #line 253 "noit_tokenizer.c" |
---|
252 | 253 | yy37: |
---|
253 | 254 | ++t->next; |
---|
254 | | #line 106 "noit_tokenizer.re" |
---|
| 255 | #line 107 "noit_tokenizer.re" |
---|
255 | 256 | { goto dqstring; } |
---|
256 | | #line 257 "noit_tokenizer.c" |
---|
| 257 | #line 258 "noit_tokenizer.c" |
---|
257 | 258 | } |
---|
258 | | #line 114 "noit_tokenizer.re" |
---|
| 259 | #line 115 "noit_tokenizer.re" |
---|
259 | 260 | |
---|
260 | 261 | } |
---|
r37cf7d8 |
r6210da7 |
|
| 1 | #include "noit_defines.h" |
---|
1 | 2 | #include <stdlib.h> |
---|
2 | 3 | #include <string.h> |
---|
r21b0c6c |
r6210da7 |
|
87 | 87 | const char *key, *value; |
---|
88 | 88 | int klen; |
---|
89 | | while(noit_hash_next(table, &iter, &key, &klen, (void **)&value)) { |
---|
| 89 | while(noit_hash_next_str(table, &iter, &key, &klen, &value)) { |
---|
90 | 90 | int subrv; |
---|
91 | 91 | if((subrv = eventer_propset(key, value)) != 0) |
---|
r6480ae1 |
r6210da7 |
|
776 | 776 | |
---|
777 | 777 | if (!found) { |
---|
778 | | #ifdef SDEBUG} |
---|
| 778 | #ifdef SDEBUG |
---|
779 | 779 | (void) fprintf(el->el_errfile, "not found\n"); |
---|
780 | 780 | #endif |
---|
rdbaf64b |
r6210da7 |
|
107 | 107 | conn_q * |
---|
108 | 108 | __get_conn_q_for_remote(struct sockaddr *remote) { |
---|
| 109 | void *vcq; |
---|
109 | 110 | conn_q *cq; |
---|
110 | 111 | char queue_name[128] = "datastore_"; |
---|
… | … | |
136 | 137 | len = 4; |
---|
137 | 138 | } |
---|
138 | | if(noit_hash_retrieve(&ds_conns, (const char *)remote, len, (void **)&cq)) |
---|
139 | | return cq; |
---|
| 139 | if(noit_hash_retrieve(&ds_conns, (const char *)remote, len, &vcq)) |
---|
| 140 | return vcq; |
---|
140 | 141 | cq = calloc(1, sizeof(*cq)); |
---|
141 | 142 | cq->remote = malloc(len); |
---|
… | … | |
435 | 436 | dsn[0] = '\0'; |
---|
436 | 437 | t = noit_conf_get_hash(NULL, "/stratcon/database/dbconfig"); |
---|
437 | | while(noit_hash_next(t, &iter, &k, &klen, (void **)&v)) { |
---|
| 438 | while(noit_hash_next_str(t, &iter, &k, &klen, &v)) { |
---|
438 | 439 | if(dsn[0]) strlcat(dsn, " ", sizeof(dsn)); |
---|
439 | 440 | strlcat(dsn, k, sizeof(dsn)); |
---|
r21b0c6c |
r6210da7 |
|
77 | 77 | const char *v; |
---|
78 | 78 | u_int32_t min_interval = 1000, max_interval = 60000; |
---|
79 | | if(noit_hash_retrieve(ctx->config, |
---|
| 79 | if(noit_hash_retr_str(ctx->config, |
---|
80 | 80 | "reconnect_initial_interval", |
---|
81 | 81 | strlen("reconnect_initial_interval"), |
---|
82 | | (void **)&v)) { |
---|
| 82 | &v)) { |
---|
83 | 83 | min_interval = MAX(atoi(v), 100); /* .1 second minimum */ |
---|
84 | 84 | } |
---|
85 | | if(noit_hash_retrieve(ctx->config, |
---|
| 85 | if(noit_hash_retr_str(ctx->config, |
---|
86 | 86 | "reconnect_maximum_interval", |
---|
87 | 87 | strlen("reconnect_maximum_interval"), |
---|
88 | | (void **)&v)) { |
---|
| 88 | &v)) { |
---|
89 | 89 | max_interval = MIN(atoi(v), 3600*1000); /* 1 hour maximum */ |
---|
90 | 90 | } |
---|
… | … | |
157 | 157 | ctx->buffer = malloc(size + 1); \ |
---|
158 | 158 | if(ctx->buffer == NULL) { \ |
---|
159 | | noitL(noit_error, "malloc(%lu) failed.\n", size + 1); \ |
---|
| 159 | noitL(noit_error, "malloc(%lu) failed.\n", (long unsigned int)size + 1); \ |
---|
160 | 160 | goto socket_error; \ |
---|
161 | 161 | } \ |
---|
… | … | |
172 | 172 | if(len != size) { \ |
---|
173 | 173 | noitL(noit_error, "SSL short read [%d] (%d/%lu). Reseting connection.\n", \ |
---|
174 | | ctx->state, len, size); \ |
---|
| 174 | ctx->state, len, (long unsigned int)size); \ |
---|
175 | 175 | goto socket_error; \ |
---|
176 | 176 | } \ |
---|
… | … | |
324 | 324 | struct timeval *now) { |
---|
325 | 325 | noit_connection_ctx_t *nctx = closure; |
---|
326 | | char *cert, *key, *ca, *ciphers; |
---|
| 326 | const char *cert, *key, *ca, *ciphers; |
---|
327 | 327 | eventer_ssl_ctx_t *sslctx; |
---|
328 | 328 | |
---|
… | … | |
336 | 336 | |
---|
337 | 337 | #define SSLCONFGET(var,name) do { \ |
---|
338 | | if(!noit_hash_retrieve(nctx->sslconfig, name, strlen(name), \ |
---|
339 | | (void **)&var)) var = NULL; } while(0) |
---|
| 338 | if(!noit_hash_retr_str(nctx->sslconfig, name, strlen(name), \ |
---|
| 339 | &var)) var = NULL; } while(0) |
---|
340 | 340 | SSLCONFGET(cert, "certificate_file"); |
---|
341 | 341 | SSLCONFGET(key, "key_file"); |
---|
r2cc7e9e |
r6210da7 |
|
371 | 371 | noitL(noit_error, "http: %s %s %s\n", |
---|
372 | 372 | req->method_str, req->uri_str, req->protocol_str); |
---|
373 | | while(noit_hash_next(&req->headers, &iter, &key, &klen, (void **)&value)) { |
---|
| 373 | while(noit_hash_next_str(&req->headers, &iter, &key, &klen, &value)) { |
---|
374 | 374 | noitL(noit_error, "http: [%s: %s]\n", key, value); |
---|
375 | 375 | } |
---|
r55168c7 |
r6210da7 |
|
80 | 80 | const char *key, *value; |
---|
81 | 81 | int klen; |
---|
82 | | while(noit_hash_next(table, &iter, &key, &klen, (void **)&value)) { |
---|
| 82 | while(noit_hash_next_str(table, &iter, &key, &klen, &value)) { |
---|
83 | 83 | int subrv; |
---|
84 | 84 | if((subrv = eventer_propset(key, value)) != 0) |
---|
rf99cf46 |
r6210da7 |
|
309 | 309 | } |
---|
310 | 310 | |
---|
| 311 | int noit_hash_next_str(noit_hash_table *h, noit_hash_iter *iter, |
---|
| 312 | const char **k, int *klen, const char **dstr) { |
---|
| 313 | void *data = NULL; |
---|
| 314 | int rv; |
---|
| 315 | rv = noit_hash_next(h,iter,k,klen,&data); |
---|
| 316 | *dstr = data; |
---|
| 317 | return rv; |
---|
| 318 | } |
---|
| 319 | |
---|
311 | 320 | int noit_hash_firstkey(noit_hash_table *h, const char **k, int *klen) { |
---|
312 | 321 | int i; |
---|
rf99cf46 |
r6210da7 |
|
76 | 76 | NoitHashFreeFunc keyfree, NoitHashFreeFunc datafree); |
---|
77 | 77 | int noit_hash_retrieve(noit_hash_table *h, const char *k, int klen, void **data); |
---|
78 | | int noit_hash_retr_str(noit_hash_table *h, const char *k, int klen, const char **data); |
---|
| 78 | int noit_hash_retr_str(noit_hash_table *h, const char *k, int klen, const char **dstr); |
---|
79 | 79 | int noit_hash_delete(noit_hash_table *h, const char *k, int klen, |
---|
80 | 80 | NoitHashFreeFunc keyfree, NoitHashFreeFunc datafree); |
---|
… | … | |
106 | 106 | int noit_hash_next(noit_hash_table *h, noit_hash_iter *iter, |
---|
107 | 107 | const char **k, int *klen, void **data); |
---|
| 108 | int noit_hash_next_str(noit_hash_table *h, noit_hash_iter *iter, |
---|
| 109 | const char **k, int *klen, const char **dstr); |
---|
108 | 110 | int noit_hash_firstkey(noit_hash_table *h, const char **k, int *klen); |
---|
109 | 111 | int noit_hash_nextkey(noit_hash_table *h, const char **k, int *klen, const char *lk, int lklen); |
---|