static int on_config_virtual_host(h2o_configurator_t *configurator, void *_config, const char *file, yoml_t *node) { h2o_global_configuration_t *config = _config; size_t i; if (node->type != YOML_TYPE_MAPPING) { h2o_config_print_error(configurator, file, node, "argument must be a mapping"); return -1; } for (i = 0; i != node->data.mapping.size; ++i) { yoml_t *key = node->data.mapping.elements[i].key; yoml_t *value = node->data.mapping.elements[i].value; h2o_host_configuration_t *host_config; if (key->type != YOML_TYPE_SCALAR) { h2o_config_print_error(configurator, file, key, "key (representing the hostname) must be a string"); return -1; } host_config = h2o_config_register_virtual_host(config, key->data.scalar); if (apply_commands(host_config, file, value, config) != 0) return -1; } return 0; }
int h2o_config_configure(h2o_global_configuration_t *config, const char *file, yoml_t *node) { init_core_configurators(config); /* apply the configuration */ if (apply_commands(config, file, node, config) != 0) return -1; /* call the complete callbacks */ if (complete_configurators(&config->global_configurators, config) != 0) return -1; if (for_each_host_context(config, complete_host_configurators, &config->host_configurators) != 0) return -1; return 0; }
void execute(const struct command *commands, size_t mlen, const uint8_t *cores, size_t rlen) { uint64_t *times = alloca(mlen * sizeof(uint64_t)); uint64_t start = getnow(), now, next; struct timespec ts; msrval_t *values; msradr_t *addresses; values = alloca(mlen * rlen * sizeof (msrval_t)); addresses = alloca(mlen * rlen * sizeof (msradr_t)); print_header(commands, mlen, cores, rlen); signal(SIGINT, handle_signal); signal(SIGTERM, handle_signal); signal(SIGQUIT, handle_signal); setup_start_data(addresses, commands, mlen, rlen); setup_next_data(values, commands, mlen, rlen); setup_start_times(times, commands, mlen, start); while (!stopped) { now = getnow(); apply_commands(values, addresses, times, commands, mlen, cores, rlen, now); print_data(times, values, commands, mlen, rlen, start, now); next = setup_next_times(times, commands, mlen, now); if (next == ~(0ul)) break; setup_next_data(values, commands, mlen, rlen); ts.tv_sec = (next - now) / 1000; ts.tv_nsec = ((next - now) - ts.tv_sec * 1000) * 1000000; nanosleep(&ts, NULL); } }