diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2008-08-21 18:47:23 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2008-08-21 18:47:23 +0000 |
| commit | 6a75019ad6847a5bf8c0dcd1f0ad87ed715add7e (patch) | |
| tree | f7feb9bb2be60866bf079e19c0736dc0d3f160f3 /src/core/ngx_connection.c | |
| parent | bbe42c41e8f883185745706f92426aa9e73b3eab (diff) | |
| download | nginx-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 'src/core/ngx_connection.c')
| -rw-r--r-- | src/core/ngx_connection.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 03662b398..827477501 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -37,12 +37,13 @@ ngx_listening_inet_stream_socket(ngx_conf_t *cf, in_addr_t addr, in_port_t port) ls->addr_text.data = ngx_pnalloc(cf->pool, - INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); + NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1); if (ls->addr_text.data == NULL) { return NULL; } - len = ngx_inet_ntop(AF_INET, &addr, ls->addr_text.data, INET_ADDRSTRLEN); + len = ngx_inet_ntop(AF_INET, &addr, ls->addr_text.data, + NGX_INET_ADDRSTRLEN); ls->addr_text.len = ngx_sprintf(ls->addr_text.data + len, ":%d", port) - ls->addr_text.data; @@ -53,7 +54,7 @@ ngx_listening_inet_stream_socket(ngx_conf_t *cf, in_addr_t addr, in_port_t port) ls->sockaddr = (struct sockaddr *) sin; ls->socklen = sizeof(struct sockaddr_in); ls->addr = offsetof(struct sockaddr_in, sin_addr); - ls->addr_text_max_len = INET_ADDRSTRLEN; + ls->addr_text_max_len = NGX_INET_ADDRSTRLEN; return ls; } @@ -104,17 +105,17 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle) continue; } - ls[i].addr_text_max_len = INET_ADDRSTRLEN; + ls[i].addr_text_max_len = NGX_INET_ADDRSTRLEN; ls[i].addr_text.data = ngx_pnalloc(cycle->pool, - INET_ADDRSTRLEN - 1 + sizeof(":65535") - 1); + NGX_INET_ADDRSTRLEN + sizeof(":65535") - 1); if (ls[i].addr_text.data == NULL) { return NGX_ERROR; } ls[i].family = sin->sin_family; len = ngx_sock_ntop(ls[i].family, ls[i].sockaddr, - ls[i].addr_text.data, INET_ADDRSTRLEN); + ls[i].addr_text.data, NGX_INET_ADDRSTRLEN); if (len == 0) { return NGX_ERROR; } |
