odissey: support listen host '*'

This commit is contained in:
Dmitry Simonenko 2017-04-05 14:48:26 +03:00
parent 64011392e4
commit 976f677d7f
3 changed files with 23 additions and 6 deletions

View File

@ -89,12 +89,29 @@ od_pooler(void *arg)
if (rc == -1) if (rc == -1)
return; return;
/* listen '*' */
struct addrinfo *hints_ptr = NULL;
struct addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
hints.ai_protocol = 0;
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
char *host = env->scheme.host;
if (strcmp(env->scheme.host, "*") == 0) {
hints_ptr = &hints;
host = NULL;
}
/* resolve listen address and port */ /* resolve listen address and port */
char port[16]; char port[16];
snprintf(port, sizeof(port), "%d", env->scheme.port); snprintf(port, sizeof(port), "%d", env->scheme.port);
struct addrinfo *ai = NULL; struct addrinfo *ai = NULL;
rc = machine_getaddrinfo(pooler->server, rc = machine_getaddrinfo(pooler->server, host, port,
env->scheme.host, port, NULL, &ai, 0); hints_ptr, &ai, 0);
if (rc < 0) { if (rc < 0) {
od_error(&env->log, NULL, "failed to resolve %s:%d", od_error(&env->log, NULL, "failed to resolve %s:%d",
env->scheme.host, env->scheme.host,

View File

@ -206,7 +206,7 @@ int od_schemevalidate(od_scheme_t *scheme, od_log_t *log)
/* listen */ /* listen */
if (scheme->host == NULL) if (scheme->host == NULL)
scheme->host = "127.0.0.1"; scheme->host = "*";
/* tls */ /* tls */
if (scheme->tls_mode) { if (scheme->tls_mode) {

View File

@ -13,15 +13,15 @@ odissey {
pooling "transaction" pooling "transaction"
listen { listen {
host "localhost" host "*"
port 6432 port 6432
nodelay yes nodelay yes
# backlog 16 # backlog 16
# keepalive 7200 # keepalive 7200
tls_mode "disable" tls_mode "disable"
# tls_ca_file ""
# tls_key_file ""
# tls_cert_file "" # tls_cert_file ""
# tls_key_file ""
# tls_ca_file ""
# tls_protocols "" # tls_protocols ""
workers 8 workers 8
client_max 100 client_max 100