Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #include <ngx_config.h>
0009 #include <ngx_core.h>
0010 #include <ngx_stream.h>
0011 
0012 
0013 static ngx_int_t ngx_stream_upstream_add_variables(ngx_conf_t *cf);
0014 static ngx_int_t ngx_stream_upstream_addr_variable(ngx_stream_session_t *s,
0015     ngx_stream_variable_value_t *v, uintptr_t data);
0016 static ngx_int_t ngx_stream_upstream_response_time_variable(
0017     ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data);
0018 static ngx_int_t ngx_stream_upstream_bytes_variable(ngx_stream_session_t *s,
0019     ngx_stream_variable_value_t *v, uintptr_t data);
0020 
0021 static char *ngx_stream_upstream(ngx_conf_t *cf, ngx_command_t *cmd,
0022     void *dummy);
0023 static char *ngx_stream_upstream_server(ngx_conf_t *cf, ngx_command_t *cmd,
0024     void *conf);
0025 static void *ngx_stream_upstream_create_main_conf(ngx_conf_t *cf);
0026 static char *ngx_stream_upstream_init_main_conf(ngx_conf_t *cf, void *conf);
0027 
0028 
0029 static ngx_command_t  ngx_stream_upstream_commands[] = {
0030 
0031     { ngx_string("upstream"),
0032       NGX_STREAM_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE1,
0033       ngx_stream_upstream,
0034       0,
0035       0,
0036       NULL },
0037 
0038     { ngx_string("server"),
0039       NGX_STREAM_UPS_CONF|NGX_CONF_1MORE,
0040       ngx_stream_upstream_server,
0041       NGX_STREAM_SRV_CONF_OFFSET,
0042       0,
0043       NULL },
0044 
0045       ngx_null_command
0046 };
0047 
0048 
0049 static ngx_stream_module_t  ngx_stream_upstream_module_ctx = {
0050     ngx_stream_upstream_add_variables,     /* preconfiguration */
0051     NULL,                                  /* postconfiguration */
0052 
0053     ngx_stream_upstream_create_main_conf,  /* create main configuration */
0054     ngx_stream_upstream_init_main_conf,    /* init main configuration */
0055 
0056     NULL,                                  /* create server configuration */
0057     NULL                                   /* merge server configuration */
0058 };
0059 
0060 
0061 ngx_module_t  ngx_stream_upstream_module = {
0062     NGX_MODULE_V1,
0063     &ngx_stream_upstream_module_ctx,       /* module context */
0064     ngx_stream_upstream_commands,          /* module directives */
0065     NGX_STREAM_MODULE,                     /* module type */
0066     NULL,                                  /* init master */
0067     NULL,                                  /* init module */
0068     NULL,                                  /* init process */
0069     NULL,                                  /* init thread */
0070     NULL,                                  /* exit thread */
0071     NULL,                                  /* exit process */
0072     NULL,                                  /* exit master */
0073     NGX_MODULE_V1_PADDING
0074 };
0075 
0076 
0077 static ngx_stream_variable_t  ngx_stream_upstream_vars[] = {
0078 
0079     { ngx_string("upstream_addr"), NULL,
0080       ngx_stream_upstream_addr_variable, 0,
0081       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0082 
0083     { ngx_string("upstream_bytes_sent"), NULL,
0084       ngx_stream_upstream_bytes_variable, 0,
0085       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0086 
0087     { ngx_string("upstream_connect_time"), NULL,
0088       ngx_stream_upstream_response_time_variable, 2,
0089       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0090 
0091     { ngx_string("upstream_first_byte_time"), NULL,
0092       ngx_stream_upstream_response_time_variable, 1,
0093       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0094 
0095     { ngx_string("upstream_session_time"), NULL,
0096       ngx_stream_upstream_response_time_variable, 0,
0097       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0098 
0099     { ngx_string("upstream_bytes_received"), NULL,
0100       ngx_stream_upstream_bytes_variable, 1,
0101       NGX_STREAM_VAR_NOCACHEABLE, 0 },
0102 
0103     { ngx_null_string, NULL, NULL, 0, 0, 0 }
0104 };
0105 
0106 
0107 static ngx_int_t
0108 ngx_stream_upstream_add_variables(ngx_conf_t *cf)
0109 {
0110     ngx_stream_variable_t  *var, *v;
0111 
0112     for (v = ngx_stream_upstream_vars; v->name.len; v++) {
0113         var = ngx_stream_add_variable(cf, &v->name, v->flags);
0114         if (var == NULL) {
0115             return NGX_ERROR;
0116         }
0117 
0118         var->get_handler = v->get_handler;
0119         var->data = v->data;
0120     }
0121 
0122     return NGX_OK;
0123 }
0124 
0125 
0126 static ngx_int_t
0127 ngx_stream_upstream_addr_variable(ngx_stream_session_t *s,
0128     ngx_stream_variable_value_t *v, uintptr_t data)
0129 {
0130     u_char                       *p;
0131     size_t                        len;
0132     ngx_uint_t                    i;
0133     ngx_stream_upstream_state_t  *state;
0134 
0135     v->valid = 1;
0136     v->no_cacheable = 0;
0137     v->not_found = 0;
0138 
0139     if (s->upstream_states == NULL || s->upstream_states->nelts == 0) {
0140         v->not_found = 1;
0141         return NGX_OK;
0142     }
0143 
0144     len = 0;
0145     state = s->upstream_states->elts;
0146 
0147     for (i = 0; i < s->upstream_states->nelts; i++) {
0148         if (state[i].peer) {
0149             len += state[i].peer->len;
0150         }
0151 
0152         len += 2;
0153     }
0154 
0155     p = ngx_pnalloc(s->connection->pool, len);
0156     if (p == NULL) {
0157         return NGX_ERROR;
0158     }
0159 
0160     v->data = p;
0161 
0162     i = 0;
0163 
0164     for ( ;; ) {
0165         if (state[i].peer) {
0166             p = ngx_cpymem(p, state[i].peer->data, state[i].peer->len);
0167         }
0168 
0169         if (++i == s->upstream_states->nelts) {
0170             break;
0171         }
0172 
0173         *p++ = ',';
0174         *p++ = ' ';
0175     }
0176 
0177     v->len = p - v->data;
0178 
0179     return NGX_OK;
0180 }
0181 
0182 
0183 static ngx_int_t
0184 ngx_stream_upstream_bytes_variable(ngx_stream_session_t *s,
0185     ngx_stream_variable_value_t *v, uintptr_t data)
0186 {
0187     u_char                       *p;
0188     size_t                        len;
0189     ngx_uint_t                    i;
0190     ngx_stream_upstream_state_t  *state;
0191 
0192     v->valid = 1;
0193     v->no_cacheable = 0;
0194     v->not_found = 0;
0195 
0196     if (s->upstream_states == NULL || s->upstream_states->nelts == 0) {
0197         v->not_found = 1;
0198         return NGX_OK;
0199     }
0200 
0201     len = s->upstream_states->nelts * (NGX_OFF_T_LEN + 2);
0202 
0203     p = ngx_pnalloc(s->connection->pool, len);
0204     if (p == NULL) {
0205         return NGX_ERROR;
0206     }
0207 
0208     v->data = p;
0209 
0210     i = 0;
0211     state = s->upstream_states->elts;
0212 
0213     for ( ;; ) {
0214 
0215         if (data == 1) {
0216             p = ngx_sprintf(p, "%O", state[i].bytes_received);
0217 
0218         } else {
0219             p = ngx_sprintf(p, "%O", state[i].bytes_sent);
0220         }
0221 
0222         if (++i == s->upstream_states->nelts) {
0223             break;
0224         }
0225 
0226         *p++ = ',';
0227         *p++ = ' ';
0228     }
0229 
0230     v->len = p - v->data;
0231 
0232     return NGX_OK;
0233 }
0234 
0235 
0236 static ngx_int_t
0237 ngx_stream_upstream_response_time_variable(ngx_stream_session_t *s,
0238     ngx_stream_variable_value_t *v, uintptr_t data)
0239 {
0240     u_char                       *p;
0241     size_t                        len;
0242     ngx_uint_t                    i;
0243     ngx_msec_int_t                ms;
0244     ngx_stream_upstream_state_t  *state;
0245 
0246     v->valid = 1;
0247     v->no_cacheable = 0;
0248     v->not_found = 0;
0249 
0250     if (s->upstream_states == NULL || s->upstream_states->nelts == 0) {
0251         v->not_found = 1;
0252         return NGX_OK;
0253     }
0254 
0255     len = s->upstream_states->nelts * (NGX_TIME_T_LEN + 4 + 2);
0256 
0257     p = ngx_pnalloc(s->connection->pool, len);
0258     if (p == NULL) {
0259         return NGX_ERROR;
0260     }
0261 
0262     v->data = p;
0263 
0264     i = 0;
0265     state = s->upstream_states->elts;
0266 
0267     for ( ;; ) {
0268 
0269         if (data == 1) {
0270             if (state[i].first_byte_time == (ngx_msec_t) -1) {
0271                 *p++ = '-';
0272                 goto next;
0273             }
0274 
0275             ms = state[i].first_byte_time;
0276 
0277         } else if (data == 2 && state[i].connect_time != (ngx_msec_t) -1) {
0278             ms = state[i].connect_time;
0279 
0280         } else {
0281             ms = state[i].response_time;
0282         }
0283 
0284         ms = ngx_max(ms, 0);
0285         p = ngx_sprintf(p, "%T.%03M", (time_t) ms / 1000, ms % 1000);
0286 
0287     next:
0288 
0289         if (++i == s->upstream_states->nelts) {
0290             break;
0291         }
0292 
0293         *p++ = ',';
0294         *p++ = ' ';
0295     }
0296 
0297     v->len = p - v->data;
0298 
0299     return NGX_OK;
0300 }
0301 
0302 
0303 static char *
0304 ngx_stream_upstream(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
0305 {
0306     char                            *rv;
0307     void                            *mconf;
0308     ngx_str_t                       *value;
0309     ngx_url_t                        u;
0310     ngx_uint_t                       m;
0311     ngx_conf_t                       pcf;
0312     ngx_stream_module_t             *module;
0313     ngx_stream_conf_ctx_t           *ctx, *stream_ctx;
0314     ngx_stream_upstream_srv_conf_t  *uscf;
0315 
0316     ngx_memzero(&u, sizeof(ngx_url_t));
0317 
0318     value = cf->args->elts;
0319     u.host = value[1];
0320     u.no_resolve = 1;
0321     u.no_port = 1;
0322 
0323     uscf = ngx_stream_upstream_add(cf, &u, NGX_STREAM_UPSTREAM_CREATE
0324                                            |NGX_STREAM_UPSTREAM_WEIGHT
0325                                            |NGX_STREAM_UPSTREAM_MAX_CONNS
0326                                            |NGX_STREAM_UPSTREAM_MAX_FAILS
0327                                            |NGX_STREAM_UPSTREAM_FAIL_TIMEOUT
0328                                            |NGX_STREAM_UPSTREAM_DOWN
0329                                            |NGX_STREAM_UPSTREAM_BACKUP);
0330     if (uscf == NULL) {
0331         return NGX_CONF_ERROR;
0332     }
0333 
0334 
0335     ctx = ngx_pcalloc(cf->pool, sizeof(ngx_stream_conf_ctx_t));
0336     if (ctx == NULL) {
0337         return NGX_CONF_ERROR;
0338     }
0339 
0340     stream_ctx = cf->ctx;
0341     ctx->main_conf = stream_ctx->main_conf;
0342 
0343     /* the upstream{}'s srv_conf */
0344 
0345     ctx->srv_conf = ngx_pcalloc(cf->pool,
0346                                 sizeof(void *) * ngx_stream_max_module);
0347     if (ctx->srv_conf == NULL) {
0348         return NGX_CONF_ERROR;
0349     }
0350 
0351     ctx->srv_conf[ngx_stream_upstream_module.ctx_index] = uscf;
0352 
0353     uscf->srv_conf = ctx->srv_conf;
0354 
0355     for (m = 0; cf->cycle->modules[m]; m++) {
0356         if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) {
0357             continue;
0358         }
0359 
0360         module = cf->cycle->modules[m]->ctx;
0361 
0362         if (module->create_srv_conf) {
0363             mconf = module->create_srv_conf(cf);
0364             if (mconf == NULL) {
0365                 return NGX_CONF_ERROR;
0366             }
0367 
0368             ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf;
0369         }
0370     }
0371 
0372     uscf->servers = ngx_array_create(cf->pool, 4,
0373                                      sizeof(ngx_stream_upstream_server_t));
0374     if (uscf->servers == NULL) {
0375         return NGX_CONF_ERROR;
0376     }
0377 
0378 
0379     /* parse inside upstream{} */
0380 
0381     pcf = *cf;
0382     cf->ctx = ctx;
0383     cf->cmd_type = NGX_STREAM_UPS_CONF;
0384 
0385     rv = ngx_conf_parse(cf, NULL);
0386 
0387     *cf = pcf;
0388 
0389     if (rv != NGX_CONF_OK) {
0390         return rv;
0391     }
0392 
0393     if (uscf->servers->nelts == 0) {
0394         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0395                            "no servers are inside upstream");
0396         return NGX_CONF_ERROR;
0397     }
0398 
0399     return rv;
0400 }
0401 
0402 
0403 static char *
0404 ngx_stream_upstream_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
0405 {
0406     ngx_stream_upstream_srv_conf_t  *uscf = conf;
0407 
0408     time_t                         fail_timeout;
0409     ngx_str_t                     *value, s;
0410     ngx_url_t                      u;
0411     ngx_int_t                      weight, max_conns, max_fails;
0412     ngx_uint_t                     i;
0413     ngx_stream_upstream_server_t  *us;
0414 
0415     us = ngx_array_push(uscf->servers);
0416     if (us == NULL) {
0417         return NGX_CONF_ERROR;
0418     }
0419 
0420     ngx_memzero(us, sizeof(ngx_stream_upstream_server_t));
0421 
0422     value = cf->args->elts;
0423 
0424     weight = 1;
0425     max_conns = 0;
0426     max_fails = 1;
0427     fail_timeout = 10;
0428 
0429     for (i = 2; i < cf->args->nelts; i++) {
0430 
0431         if (ngx_strncmp(value[i].data, "weight=", 7) == 0) {
0432 
0433             if (!(uscf->flags & NGX_STREAM_UPSTREAM_WEIGHT)) {
0434                 goto not_supported;
0435             }
0436 
0437             weight = ngx_atoi(&value[i].data[7], value[i].len - 7);
0438 
0439             if (weight == NGX_ERROR || weight == 0) {
0440                 goto invalid;
0441             }
0442 
0443             continue;
0444         }
0445 
0446         if (ngx_strncmp(value[i].data, "max_conns=", 10) == 0) {
0447 
0448             if (!(uscf->flags & NGX_STREAM_UPSTREAM_MAX_CONNS)) {
0449                 goto not_supported;
0450             }
0451 
0452             max_conns = ngx_atoi(&value[i].data[10], value[i].len - 10);
0453 
0454             if (max_conns == NGX_ERROR) {
0455                 goto invalid;
0456             }
0457 
0458             continue;
0459         }
0460 
0461         if (ngx_strncmp(value[i].data, "max_fails=", 10) == 0) {
0462 
0463             if (!(uscf->flags & NGX_STREAM_UPSTREAM_MAX_FAILS)) {
0464                 goto not_supported;
0465             }
0466 
0467             max_fails = ngx_atoi(&value[i].data[10], value[i].len - 10);
0468 
0469             if (max_fails == NGX_ERROR) {
0470                 goto invalid;
0471             }
0472 
0473             continue;
0474         }
0475 
0476         if (ngx_strncmp(value[i].data, "fail_timeout=", 13) == 0) {
0477 
0478             if (!(uscf->flags & NGX_STREAM_UPSTREAM_FAIL_TIMEOUT)) {
0479                 goto not_supported;
0480             }
0481 
0482             s.len = value[i].len - 13;
0483             s.data = &value[i].data[13];
0484 
0485             fail_timeout = ngx_parse_time(&s, 1);
0486 
0487             if (fail_timeout == (time_t) NGX_ERROR) {
0488                 goto invalid;
0489             }
0490 
0491             continue;
0492         }
0493 
0494         if (ngx_strcmp(value[i].data, "backup") == 0) {
0495 
0496             if (!(uscf->flags & NGX_STREAM_UPSTREAM_BACKUP)) {
0497                 goto not_supported;
0498             }
0499 
0500             us->backup = 1;
0501 
0502             continue;
0503         }
0504 
0505         if (ngx_strcmp(value[i].data, "down") == 0) {
0506 
0507             if (!(uscf->flags & NGX_STREAM_UPSTREAM_DOWN)) {
0508                 goto not_supported;
0509             }
0510 
0511             us->down = 1;
0512 
0513             continue;
0514         }
0515 
0516         goto invalid;
0517     }
0518 
0519     ngx_memzero(&u, sizeof(ngx_url_t));
0520 
0521     u.url = value[1];
0522 
0523     if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
0524         if (u.err) {
0525             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0526                                "%s in upstream \"%V\"", u.err, &u.url);
0527         }
0528 
0529         return NGX_CONF_ERROR;
0530     }
0531 
0532     if (u.no_port) {
0533         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0534                            "no port in upstream \"%V\"", &u.url);
0535         return NGX_CONF_ERROR;
0536     }
0537 
0538     us->name = u.url;
0539     us->addrs = u.addrs;
0540     us->naddrs = u.naddrs;
0541     us->weight = weight;
0542     us->max_conns = max_conns;
0543     us->max_fails = max_fails;
0544     us->fail_timeout = fail_timeout;
0545 
0546     return NGX_CONF_OK;
0547 
0548 invalid:
0549 
0550     ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0551                        "invalid parameter \"%V\"", &value[i]);
0552 
0553     return NGX_CONF_ERROR;
0554 
0555 not_supported:
0556 
0557     ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0558                        "balancing method does not support parameter \"%V\"",
0559                        &value[i]);
0560 
0561     return NGX_CONF_ERROR;
0562 }
0563 
0564 
0565 ngx_stream_upstream_srv_conf_t *
0566 ngx_stream_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags)
0567 {
0568     ngx_uint_t                        i;
0569     ngx_stream_upstream_server_t     *us;
0570     ngx_stream_upstream_srv_conf_t   *uscf, **uscfp;
0571     ngx_stream_upstream_main_conf_t  *umcf;
0572 
0573     if (!(flags & NGX_STREAM_UPSTREAM_CREATE)) {
0574 
0575         if (ngx_parse_url(cf->pool, u) != NGX_OK) {
0576             if (u->err) {
0577                 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0578                                    "%s in upstream \"%V\"", u->err, &u->url);
0579             }
0580 
0581             return NULL;
0582         }
0583     }
0584 
0585     umcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_upstream_module);
0586 
0587     uscfp = umcf->upstreams.elts;
0588 
0589     for (i = 0; i < umcf->upstreams.nelts; i++) {
0590 
0591         if (uscfp[i]->host.len != u->host.len
0592             || ngx_strncasecmp(uscfp[i]->host.data, u->host.data, u->host.len)
0593                != 0)
0594         {
0595             continue;
0596         }
0597 
0598         if ((flags & NGX_STREAM_UPSTREAM_CREATE)
0599              && (uscfp[i]->flags & NGX_STREAM_UPSTREAM_CREATE))
0600         {
0601             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0602                                "duplicate upstream \"%V\"", &u->host);
0603             return NULL;
0604         }
0605 
0606         if ((uscfp[i]->flags & NGX_STREAM_UPSTREAM_CREATE) && !u->no_port) {
0607             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
0608                                "upstream \"%V\" may not have port %d",
0609                                &u->host, u->port);
0610             return NULL;
0611         }
0612 
0613         if ((flags & NGX_STREAM_UPSTREAM_CREATE) && !uscfp[i]->no_port) {
0614             ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
0615                           "upstream \"%V\" may not have port %d in %s:%ui",
0616                           &u->host, uscfp[i]->port,
0617                           uscfp[i]->file_name, uscfp[i]->line);
0618             return NULL;
0619         }
0620 
0621         if (uscfp[i]->port != u->port) {
0622             continue;
0623         }
0624 
0625         if (flags & NGX_STREAM_UPSTREAM_CREATE) {
0626             uscfp[i]->flags = flags;
0627         }
0628 
0629         return uscfp[i];
0630     }
0631 
0632     uscf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_upstream_srv_conf_t));
0633     if (uscf == NULL) {
0634         return NULL;
0635     }
0636 
0637     uscf->flags = flags;
0638     uscf->host = u->host;
0639     uscf->file_name = cf->conf_file->file.name.data;
0640     uscf->line = cf->conf_file->line;
0641     uscf->port = u->port;
0642     uscf->no_port = u->no_port;
0643 
0644     if (u->naddrs == 1 && (u->port || u->family == AF_UNIX)) {
0645         uscf->servers = ngx_array_create(cf->pool, 1,
0646                                          sizeof(ngx_stream_upstream_server_t));
0647         if (uscf->servers == NULL) {
0648             return NULL;
0649         }
0650 
0651         us = ngx_array_push(uscf->servers);
0652         if (us == NULL) {
0653             return NULL;
0654         }
0655 
0656         ngx_memzero(us, sizeof(ngx_stream_upstream_server_t));
0657 
0658         us->addrs = u->addrs;
0659         us->naddrs = 1;
0660     }
0661 
0662     uscfp = ngx_array_push(&umcf->upstreams);
0663     if (uscfp == NULL) {
0664         return NULL;
0665     }
0666 
0667     *uscfp = uscf;
0668 
0669     return uscf;
0670 }
0671 
0672 
0673 static void *
0674 ngx_stream_upstream_create_main_conf(ngx_conf_t *cf)
0675 {
0676     ngx_stream_upstream_main_conf_t  *umcf;
0677 
0678     umcf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_upstream_main_conf_t));
0679     if (umcf == NULL) {
0680         return NULL;
0681     }
0682 
0683     if (ngx_array_init(&umcf->upstreams, cf->pool, 4,
0684                        sizeof(ngx_stream_upstream_srv_conf_t *))
0685         != NGX_OK)
0686     {
0687         return NULL;
0688     }
0689 
0690     return umcf;
0691 }
0692 
0693 
0694 static char *
0695 ngx_stream_upstream_init_main_conf(ngx_conf_t *cf, void *conf)
0696 {
0697     ngx_stream_upstream_main_conf_t *umcf = conf;
0698 
0699     ngx_uint_t                        i;
0700     ngx_stream_upstream_init_pt       init;
0701     ngx_stream_upstream_srv_conf_t  **uscfp;
0702 
0703     uscfp = umcf->upstreams.elts;
0704 
0705     for (i = 0; i < umcf->upstreams.nelts; i++) {
0706 
0707         init = uscfp[i]->peer.init_upstream
0708                                          ? uscfp[i]->peer.init_upstream
0709                                          : ngx_stream_upstream_init_round_robin;
0710 
0711         if (init(cf, uscfp[i]) != NGX_OK) {
0712             return NGX_CONF_ERROR;
0713         }
0714     }
0715 
0716     return NGX_CONF_OK;
0717 }