MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ngx_http_server_names

Function ngx_http_server_names

app/nginx-1.28.0/src/http/ngx_http.c:1534–1687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1532
1533
1534static ngx_int_t
1535ngx_http_server_names(ngx_conf_t *cf, ngx_http_core_main_conf_t *cmcf,
1536 ngx_http_conf_addr_t *addr)
1537{
1538 ngx_int_t rc;
1539 ngx_uint_t n, s;
1540 ngx_hash_init_t hash;
1541 ngx_hash_keys_arrays_t ha;
1542 ngx_http_server_name_t *name;
1543 ngx_http_core_srv_conf_t **cscfp;
1544#if (NGX_PCRE)
1545 ngx_uint_t regex, i;
1546
1547 regex = 0;
1548#endif
1549
1550 ngx_memzero(&ha, sizeof(ngx_hash_keys_arrays_t));
1551
1552 ha.temp_pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, cf->log);
1553 if (ha.temp_pool == NULL) {
1554 return NGX_ERROR;
1555 }
1556
1557 ha.pool = cf->pool;
1558
1559 if (ngx_hash_keys_array_init(&ha, NGX_HASH_LARGE) != NGX_OK) {
1560 goto failed;
1561 }
1562
1563 cscfp = addr->servers.elts;
1564
1565 for (s = 0; s < addr->servers.nelts; s++) {
1566
1567 name = cscfp[s]->server_names.elts;
1568
1569 for (n = 0; n < cscfp[s]->server_names.nelts; n++) {
1570
1571#if (NGX_PCRE)
1572 if (name[n].regex) {
1573 regex++;
1574 continue;
1575 }
1576#endif
1577
1578 rc = ngx_hash_add_key(&ha, &name[n].name, name[n].server,
1579 NGX_HASH_WILDCARD_KEY);
1580
1581 if (rc == NGX_ERROR) {
1582 goto failed;
1583 }
1584
1585 if (rc == NGX_DECLINED) {
1586 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
1587 "invalid server name or wildcard \"%V\" on %V",
1588 &name[n].name, &addr->opt.addr_text);
1589 goto failed;
1590 }
1591

Callers 1

Calls 8

ngx_create_poolFunction · 0.85
ngx_hash_keys_array_initFunction · 0.85
ngx_hash_add_keyFunction · 0.85
ngx_log_errorFunction · 0.85
ngx_hash_initFunction · 0.85
ngx_hash_wildcard_initFunction · 0.85
ngx_destroy_poolFunction · 0.85
ngx_pallocFunction · 0.85

Tested by

no test coverage detected