comparison src/http/modules/ngx_http_upstream_least_conn_module.c @ 4656:90ddd4abfdd2

Upstream: least_conn compilation fixes. Removed duplicate call of ngx_http_upstream_init_round_robin_peer() overlooked during code changes. Rewritten "return lcp->free_rr_peer(...)" as MSVC doesn't like it.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 04 Jun 2012 00:00:28 +0000
parents a2ca3a6ee680
children 4c36e15651f7
comparison
equal deleted inserted replaced
4655:382c523d253a 4656:90ddd4abfdd2
120 120
121 static ngx_int_t 121 static ngx_int_t
122 ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r, 122 ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r,
123 ngx_http_upstream_srv_conf_t *us) 123 ngx_http_upstream_srv_conf_t *us)
124 { 124 {
125 ngx_int_t rc;
126 ngx_http_upstream_lc_peer_data_t *lcp; 125 ngx_http_upstream_lc_peer_data_t *lcp;
127 ngx_http_upstream_least_conn_conf_t *lcf; 126 ngx_http_upstream_least_conn_conf_t *lcf;
128 127
129 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 128 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
130 "init least conn peer"); 129 "init least conn peer");
138 } 137 }
139 138
140 lcp->conns = lcf->conns; 139 lcp->conns = lcf->conns;
141 140
142 r->upstream->peer.data = &lcp->rrp; 141 r->upstream->peer.data = &lcp->rrp;
143
144 rc = ngx_http_upstream_init_round_robin_peer(r, us);
145 142
146 if (ngx_http_upstream_init_round_robin_peer(r, us) != NGX_OK) { 143 if (ngx_http_upstream_init_round_robin_peer(r, us) != NGX_OK) {
147 return NGX_ERROR; 144 return NGX_ERROR;
148 } 145 }
149 146
348 345
349 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0, 346 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
350 "free least conn peer %ui %ui", pc->tries, state); 347 "free least conn peer %ui %ui", pc->tries, state);
351 348
352 if (lcp->rrp.peers->single) { 349 if (lcp->rrp.peers->single) {
353 return lcp->free_rr_peer(pc, &lcp->rrp, state); 350 lcp->free_rr_peer(pc, &lcp->rrp, state);
351 return;
354 } 352 }
355 353
356 if (state == 0 && pc->tries == 0) { 354 if (state == 0 && pc->tries == 0) {
357 return; 355 return;
358 } 356 }
359 357
360 lcp->conns[lcp->rrp.current]--; 358 lcp->conns[lcp->rrp.current]--;
361 359
362 return lcp->free_rr_peer(pc, &lcp->rrp, state); 360 lcp->free_rr_peer(pc, &lcp->rrp, state);
363 } 361 }
364 362
365 363
366 static void * 364 static void *
367 ngx_http_upstream_least_conn_create_conf(ngx_conf_t *cf) 365 ngx_http_upstream_least_conn_create_conf(ngx_conf_t *cf)