comparison 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
comparison
equal deleted inserted replaced
291:b87a3cfad343 292:92402f034b28
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