diff src/http/modules/ngx_http_upstream_ip_hash_module.c @ 292:92402f034b28 NGINX_0_5_16

nginx 0.5.16 *) Bugfix: the C-class network was not used as hash key in the "ip_hash" directive. Thanks to Pavel Yarkovoy. *) Bugfix: a segmentation fault might occur in worker process if a charset was set in the "Content-Type" header line and the line has trailing ";"; bug appeared in 0.3.50. *) Bugfix: the "[alert] zero size buf" error when FastCGI server was used and an request body written in a temporary file was multiple of 32K. *) Bugfix: nginx could not be built on Solaris without the --with-debug option; bug appeared in 0.5.15.
author Igor Sysoev <http://sysoev.ru>
date Mon, 26 Mar 2007 00:00:00 +0400
parents f745bf973510
children fc223117327f
line wrap: on
line diff
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
@@ -93,6 +93,7 @@ static ngx_int_t
 ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r,
     ngx_http_upstream_srv_conf_t *us)
 {
+    u_char                                 *p;
     struct sockaddr_in                     *sin;
     ngx_http_upstream_ip_hash_peer_data_t  *iphp;
 
@@ -111,9 +112,10 @@ ngx_http_upstream_init_ip_hash_peer(ngx_
 
     /* AF_INET only */
     sin = (struct sockaddr_in *) r->connection->sockaddr;
-    iphp->addr[0] = (u_char) ((sin->sin_addr.s_addr >> 24) & 0xff);
-    iphp->addr[1] = (u_char) ((sin->sin_addr.s_addr >> 16) & 0xff);
-    iphp->addr[2] = (u_char) ((sin->sin_addr.s_addr >> 8) & 0xff);
+    p = (u_char *) &sin->sin_addr.s_addr;
+    iphp->addr[0] = p[0];
+    iphp->addr[1] = p[1];
+    iphp->addr[2] = p[2];
 
     iphp->hash = 89;
     iphp->tries = 0;