Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 417:0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 07 Sep 2004 15:29:22 +0000 |
parents | b9bd635011de |
children | bd39260a1383 |
comparison
equal
deleted
inserted
replaced
416:b9bd635011de | 417:0526206251f6 |
---|---|
1471 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1471 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1472 { | 1472 { |
1473 ngx_http_core_srv_conf_t *scf = conf; | 1473 ngx_http_core_srv_conf_t *scf = conf; |
1474 | 1474 |
1475 u_char *addr; | 1475 u_char *addr; |
1476 u_int p; | 1476 ngx_int_t port; |
1477 ngx_uint_t p; | |
1477 struct hostent *h; | 1478 struct hostent *h; |
1478 ngx_str_t *args; | 1479 ngx_str_t *args; |
1479 ngx_http_listen_t *ls; | 1480 ngx_http_listen_t *ls; |
1480 | 1481 |
1481 /* TODO: check duplicate 'listen' directives, | 1482 /* TODO: check duplicate 'listen' directives, |
1503 if (p == args[1].len) { | 1504 if (p == args[1].len) { |
1504 /* no ":" in the "listen" */ | 1505 /* no ":" in the "listen" */ |
1505 p = 0; | 1506 p = 0; |
1506 } | 1507 } |
1507 | 1508 |
1508 ls->port = ngx_atoi(&addr[p], args[1].len - p); | 1509 port = ngx_atoi(&addr[p], args[1].len - p); |
1509 if (ls->port == NGX_ERROR && p == 0) { | 1510 if (port == NGX_ERROR && p == 0) { |
1510 | 1511 |
1511 /* "listen host" */ | 1512 /* "listen host" */ |
1512 ls->port = 80; | 1513 ls->port = 80; |
1513 | 1514 |
1514 } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ | 1515 } else if ((port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ |
1515 || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */ | 1516 || (port < 1 || port > 65536)) { /* "listen 99999" */ |
1516 | 1517 |
1517 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1518 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1518 "invalid port \"%s\" in \"%s\" directive, " | 1519 "invalid port \"%s\" in \"%s\" directive, " |
1519 "it must be a number between 1 and 65535", | 1520 "it must be a number between 1 and 65535", |
1520 &addr[p], cmd->name.data); | 1521 &addr[p], cmd->name.data); |
1521 | 1522 |
1522 return NGX_CONF_ERROR; | 1523 return NGX_CONF_ERROR; |
1523 | 1524 |
1524 } else if (p == 0) { | 1525 } else if (p == 0) { |
1525 ls->addr = INADDR_ANY; | 1526 ls->addr = INADDR_ANY; |
1527 ls->port = (in_port_t) port; | |
1526 return NGX_CONF_OK; | 1528 return NGX_CONF_OK; |
1527 } | 1529 } |
1528 | 1530 |
1529 ls->addr = inet_addr((const char *) addr); | 1531 ls->addr = inet_addr((const char *) addr); |
1530 if (ls->addr == INADDR_NONE) { | 1532 if (ls->addr == INADDR_NONE) { |