comparison src/http/modules/ngx_http_upstream_ip_hash_module.c @ 1144:324a5a3fe27f

ip_hash used wrong byte order
author Igor Sysoev <igor@sysoev.ru>
date Fri, 23 Mar 2007 12:52:33 +0000
parents 44f7e6f36b8c
children be2b895d31e0
comparison
equal deleted inserted replaced
1143:c6c42497106c 1144:324a5a3fe27f
91 91
92 static ngx_int_t 92 static ngx_int_t
93 ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r, 93 ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r,
94 ngx_http_upstream_srv_conf_t *us) 94 ngx_http_upstream_srv_conf_t *us)
95 { 95 {
96 u_char *p;
96 struct sockaddr_in *sin; 97 struct sockaddr_in *sin;
97 ngx_http_upstream_ip_hash_peer_data_t *iphp; 98 ngx_http_upstream_ip_hash_peer_data_t *iphp;
98 99
99 iphp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_ip_hash_peer_data_t)); 100 iphp = ngx_palloc(r->pool, sizeof(ngx_http_upstream_ip_hash_peer_data_t));
100 if (iphp == NULL) { 101 if (iphp == NULL) {
109 110
110 r->upstream->peer.get = ngx_http_upstream_get_ip_hash_peer; 111 r->upstream->peer.get = ngx_http_upstream_get_ip_hash_peer;
111 112
112 /* AF_INET only */ 113 /* AF_INET only */
113 sin = (struct sockaddr_in *) r->connection->sockaddr; 114 sin = (struct sockaddr_in *) r->connection->sockaddr;
114 iphp->addr[0] = (u_char) ((sin->sin_addr.s_addr >> 24) & 0xff); 115 p = (u_char *) &sin->sin_addr.s_addr;
115 iphp->addr[1] = (u_char) ((sin->sin_addr.s_addr >> 16) & 0xff); 116 iphp->addr[0] = p[0];
116 iphp->addr[2] = (u_char) ((sin->sin_addr.s_addr >> 8) & 0xff); 117 iphp->addr[1] = p[1];
118 iphp->addr[2] = p[2];
117 119
118 iphp->hash = 89; 120 iphp->hash = 89;
119 iphp->tries = 0; 121 iphp->tries = 0;
120 iphp->get_rr_peer = ngx_http_upstream_get_round_robin_peer; 122 iphp->get_rr_peer = ngx_http_upstream_get_round_robin_peer;
121 123