refactor http listen code: remove duplicate options fields
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 942f24c..6337b15 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1213,17 +1213,13 @@
if (listen->opt.default_server) {
- if (addr[i].default_server) {
+ if (addr[i].opt.default_server) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"the duplicate default server");
return NGX_ERROR;
}
addr[i].core_srv_conf = cscf;
- addr[i].default_server = 1;
-#if (NGX_HTTP_SSL)
- addr[i].ssl = listen->opt.ssl;
-#endif
addr[i].opt = listen->opt;
}
@@ -1273,12 +1269,6 @@
addr->regex = NULL;
#endif
addr->core_srv_conf = cscf;
- addr->default_server = listen->opt.default_server;
- addr->bind = listen->opt.bind;
- addr->wildcard = listen->opt.wildcard;
-#if (NGX_HTTP_SSL)
- addr->ssl = listen->opt.ssl;
-#endif
addr->opt = listen->opt;
return ngx_http_add_names(cf, cscf, addr);
@@ -1531,17 +1521,17 @@
first = (ngx_http_conf_addr_t *) one;
second = (ngx_http_conf_addr_t *) two;
- if (first->wildcard) {
+ if (first->opt.wildcard) {
/* a wildcard address must be the last resort, shift it to the end */
return 1;
}
- if (first->bind && !second->bind) {
+ if (first->opt.bind && !second->opt.bind) {
/* shift explicit bind()ed addresses to the start */
return -1;
}
- if (!first->bind && second->bind) {
+ if (!first->opt.bind && second->opt.bind) {
/* shift explicit bind()ed addresses to the start */
return 1;
}
@@ -1582,8 +1572,8 @@
* implicit bindings go, and wildcard binding is in the end.
*/
- if (addr[last - 1].wildcard) {
- addr[last - 1].bind = 1;
+ if (addr[last - 1].opt.wildcard) {
+ addr[last - 1].opt.bind = 1;
bind_wildcard = 1;
} else {
@@ -1594,7 +1584,7 @@
while (i < last) {
- if (bind_wildcard && !addr[i].bind) {
+ if (bind_wildcard && !addr[i].opt.bind) {
i++;
continue;
}
@@ -1723,7 +1713,7 @@
addrs[i].addr = sin->sin_addr.s_addr;
addrs[i].conf.core_srv_conf = addr[i].core_srv_conf;
#if (NGX_HTTP_SSL)
- addrs[i].conf.ssl = addr[i].ssl;
+ addrs[i].conf.ssl = addr[i].opt.ssl;
#endif
if (addr[i].hash.buckets == NULL
@@ -1784,7 +1774,7 @@
addrs6[i].addr6 = sin6->sin6_addr;
addrs6[i].conf.core_srv_conf = addr[i].core_srv_conf;
#if (NGX_HTTP_SSL)
- addrs6[i].conf.ssl = addr[i].ssl;
+ addrs6[i].conf.ssl = addr[i].opt.ssl;
#endif
if (addr[i].hash.buckets == NULL
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 10c61e7..e386022 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -237,13 +237,6 @@
/* the default server configuration for this address:port */
ngx_http_core_srv_conf_t *core_srv_conf;
- unsigned default_server:1;
- unsigned bind:1;
- unsigned wildcard:1;
-#if (NGX_HTTP_SSL)
- unsigned ssl:1;
-#endif
-
ngx_http_listen_opt_t opt;
} ngx_http_conf_addr_t;