comparison src/stream/ngx_stream_upstream.c @ 6705:29bf0dbc0a77

Upstream: max_conns.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 22 Sep 2016 19:32:47 +0300
parents 9cf2dce316e5
children 2a288909abc6
comparison
equal deleted inserted replaced
6704:a44ba757851d 6705:29bf0dbc0a77
320 u.no_resolve = 1; 320 u.no_resolve = 1;
321 u.no_port = 1; 321 u.no_port = 1;
322 322
323 uscf = ngx_stream_upstream_add(cf, &u, NGX_STREAM_UPSTREAM_CREATE 323 uscf = ngx_stream_upstream_add(cf, &u, NGX_STREAM_UPSTREAM_CREATE
324 |NGX_STREAM_UPSTREAM_WEIGHT 324 |NGX_STREAM_UPSTREAM_WEIGHT
325 |NGX_STREAM_UPSTREAM_MAX_CONNS
325 |NGX_STREAM_UPSTREAM_MAX_FAILS 326 |NGX_STREAM_UPSTREAM_MAX_FAILS
326 |NGX_STREAM_UPSTREAM_FAIL_TIMEOUT 327 |NGX_STREAM_UPSTREAM_FAIL_TIMEOUT
327 |NGX_STREAM_UPSTREAM_DOWN 328 |NGX_STREAM_UPSTREAM_DOWN
328 |NGX_STREAM_UPSTREAM_BACKUP); 329 |NGX_STREAM_UPSTREAM_BACKUP);
329 if (uscf == NULL) { 330 if (uscf == NULL) {
405 ngx_stream_upstream_srv_conf_t *uscf = conf; 406 ngx_stream_upstream_srv_conf_t *uscf = conf;
406 407
407 time_t fail_timeout; 408 time_t fail_timeout;
408 ngx_str_t *value, s; 409 ngx_str_t *value, s;
409 ngx_url_t u; 410 ngx_url_t u;
410 ngx_int_t weight, max_fails; 411 ngx_int_t weight, max_conns, max_fails;
411 ngx_uint_t i; 412 ngx_uint_t i;
412 ngx_stream_upstream_server_t *us; 413 ngx_stream_upstream_server_t *us;
413 414
414 us = ngx_array_push(uscf->servers); 415 us = ngx_array_push(uscf->servers);
415 if (us == NULL) { 416 if (us == NULL) {
419 ngx_memzero(us, sizeof(ngx_stream_upstream_server_t)); 420 ngx_memzero(us, sizeof(ngx_stream_upstream_server_t));
420 421
421 value = cf->args->elts; 422 value = cf->args->elts;
422 423
423 weight = 1; 424 weight = 1;
425 max_conns = 0;
424 max_fails = 1; 426 max_fails = 1;
425 fail_timeout = 10; 427 fail_timeout = 10;
426 428
427 for (i = 2; i < cf->args->nelts; i++) { 429 for (i = 2; i < cf->args->nelts; i++) {
428 430
433 } 435 }
434 436
435 weight = ngx_atoi(&value[i].data[7], value[i].len - 7); 437 weight = ngx_atoi(&value[i].data[7], value[i].len - 7);
436 438
437 if (weight == NGX_ERROR || weight == 0) { 439 if (weight == NGX_ERROR || weight == 0) {
440 goto invalid;
441 }
442
443 continue;
444 }
445
446 if (ngx_strncmp(value[i].data, "max_conns=", 10) == 0) {
447
448 if (!(uscf->flags & NGX_STREAM_UPSTREAM_MAX_CONNS)) {
449 goto not_supported;
450 }
451
452 max_conns = ngx_atoi(&value[i].data[10], value[i].len - 10);
453
454 if (max_conns == NGX_ERROR) {
438 goto invalid; 455 goto invalid;
439 } 456 }
440 457
441 continue; 458 continue;
442 } 459 }
520 537
521 us->name = u.url; 538 us->name = u.url;
522 us->addrs = u.addrs; 539 us->addrs = u.addrs;
523 us->naddrs = u.naddrs; 540 us->naddrs = u.naddrs;
524 us->weight = weight; 541 us->weight = weight;
542 us->max_conns = max_conns;
525 us->max_fails = max_fails; 543 us->max_fails = max_fails;
526 us->fail_timeout = fail_timeout; 544 us->fail_timeout = fail_timeout;
527 545
528 return NGX_CONF_OK; 546 return NGX_CONF_OK;
529 547