summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-08-21 18:47:23 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-08-21 18:47:23 +0000
commit6a75019ad6847a5bf8c0dcd1f0ad87ed715add7e (patch)
treef7feb9bb2be60866bf079e19c0736dc0d3f160f3 /src/http
parentbbe42c41e8f883185745706f92426aa9e73b3eab (diff)
downloadnginx-6a75019ad6847a5bf8c0dcd1f0ad87ed715add7e.tar.gz
nginx-6a75019ad6847a5bf8c0dcd1f0ad87ed715add7e.tar.bz2
*) remove zero termination in ngx_inet_ntop() and ngx_sock_ntop()
*) use ngx_snprintf() in ngx_inet_ntop() and ngx_sock_ntop() as they are called just once per connection *) NGX_INET_ADDRSTRLEN
Diffstat (limited to '')
-rw-r--r--src/http/modules/ngx_http_status_module.c4
-rw-r--r--src/http/ngx_http_core_module.c4
-rw-r--r--src/http/ngx_http_core_module.h2
-rw-r--r--src/http/ngx_http_header_filter_module.c2
-rw-r--r--src/http/ngx_http_upstream_round_robin.c4
-rw-r--r--src/http/ngx_http_variables.c2
6 files changed, 9 insertions, 9 deletions
diff --git a/src/http/modules/ngx_http_status_module.c b/src/http/modules/ngx_http_status_module.c
index a2e2dbc07..000d9a8e4 100644
--- a/src/http/modules/ngx_http_status_module.c
+++ b/src/http/modules/ngx_http_status_module.c
@@ -155,7 +155,7 @@ static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx)
len = NGX_INT64_LEN /* pid */
+ 1 + NGX_INT32_LEN /* connection */
+ 1 + 1 /* state */
- + 1 + INET_ADDRSTRLEN
+ + 1 + NGX_INET_ADDRSTRLEN
+ 1 + (r->server_name ? cmcf->max_server_name_len : 1)
+ 2; /* "\r\n" */
@@ -204,7 +204,7 @@ static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx)
*(b->last++) = ' ';
b->last = ngx_cpymem(b->last, c[i].addr_text.data,
c[i].addr_text.len);
- for (n = c[i].addr_text.len; n < INET_ADDRSTRLEN; n++) {
+ for (n = c[i].addr_text.len; n < NGX_INET_ADDRSTRLEN; n++) {
*(b->last++) = ' ';
}
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 8a5e9d261..30b2c0c50 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1626,7 +1626,7 @@ ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s)
}
s->len = ngx_inet_ntop(c->listening->family, &r->in_addr,
- s->data, INET_ADDRSTRLEN);
+ s->data, NGX_INET_ADDRSTRLEN);
return NGX_OK;
}
@@ -2971,7 +2971,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ls->conf.rcvbuf = -1;
ls->conf.sndbuf = -1;
- n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, INET_ADDRSTRLEN + 6);
+ n = ngx_inet_ntop(AF_INET, &ls->addr, ls->conf.addr, NGX_INET_ADDRSTRLEN);
ngx_sprintf(&ls->conf.addr[n], ":%ui", ls->port);
if (cf->args->nelts == 2) {
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 3ecc7c33a..a42b0dac8 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -47,7 +47,7 @@ typedef struct {
ngx_uint_t deferred_accept;
#endif
- u_char addr[INET_ADDRSTRLEN + 6];
+ u_char addr[NGX_INET_ADDRSTRLEN + sizeof(":65535")];
} ngx_http_listen_conf_t;
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index 7714873e0..de9533391 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -162,7 +162,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
ngx_http_core_loc_conf_t *clcf;
ngx_http_core_srv_conf_t *cscf;
/* AF_INET only */
- u_char addr[INET_ADDRSTRLEN];
+ u_char addr[NGX_INET_ADDRSTRLEN];
r->header_sent = 1;
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index e36e68529..d9450c95c 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -281,14 +281,14 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
for (i = 0; i < ur->naddrs; i++) {
- len = INET_ADDRSTRLEN - 1 + 1 + sizeof(":65536") - 1;
+ len = NGX_INET_ADDRSTRLEN + sizeof(":65536") - 1;
p = ngx_pnalloc(r->pool, len);
if (p == NULL) {
return NGX_ERROR;
}
- len = ngx_inet_ntop(AF_INET, &ur->addrs[i], p, INET_ADDRSTRLEN);
+ len = ngx_inet_ntop(AF_INET, &ur->addrs[i], p, NGX_INET_ADDRSTRLEN);
len = ngx_sprintf(&p[len], ":%d", ur->port) - p;
sin = ngx_pcalloc(r->pool, sizeof(struct sockaddr_in));
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index cd706a2a9..15d1c6d0c 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -872,7 +872,7 @@ ngx_http_variable_server_addr(ngx_http_request_t *r,
{
ngx_str_t s;
- s.data = ngx_pnalloc(r->pool, INET_ADDRSTRLEN);
+ s.data = ngx_pnalloc(r->pool, NGX_INET_ADDRSTRLEN);
if (s.data == NULL) {
return NGX_ERROR;
}