comparison src/http/ngx_http.c @ 3229:a632dc9f3e73

fix r3225 and r3227: preserve default_server bit during listen options overwriting
author Igor Sysoev <igor@sysoev.ru>
date Thu, 22 Oct 2009 10:17:54 +0000
parents a610008bdc1a
children a7491af45540
comparison
equal deleted inserted replaced
3228:1e1e66ef3a40 3229:a632dc9f3e73
1165 ngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf, 1165 ngx_http_add_addresses(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
1166 ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt) 1166 ngx_http_conf_port_t *port, ngx_http_listen_opt_t *lsopt)
1167 { 1167 {
1168 u_char *p; 1168 u_char *p;
1169 size_t len, off; 1169 size_t len, off;
1170 ngx_uint_t i; 1170 ngx_uint_t i, default_server;
1171 struct sockaddr *sa; 1171 struct sockaddr *sa;
1172 ngx_http_conf_addr_t *addr; 1172 ngx_http_conf_addr_t *addr;
1173 1173
1174 /* 1174 /*
1175 * we can not compare whole sockaddr struct's as kernel 1175 * we can not compare whole sockaddr struct's as kernel
1207 1207
1208 if (ngx_http_add_server(cf, cscf, &addr[i]) != NGX_OK) { 1208 if (ngx_http_add_server(cf, cscf, &addr[i]) != NGX_OK) {
1209 return NGX_ERROR; 1209 return NGX_ERROR;
1210 } 1210 }
1211 1211
1212 /* preserve default_server bit during listen options overwriting */
1213 default_server = addr[i].opt.default_server;
1214
1212 if (lsopt->set) { 1215 if (lsopt->set) {
1213 1216
1214 if (addr[i].opt.set) { 1217 if (addr[i].opt.set) {
1215 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 1218 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1216 "a duplicate listen options for %s", addr[i].opt.addr); 1219 "a duplicate listen options for %s", addr[i].opt.addr);
1222 1225
1223 /* check the duplicate "default" server for this address:port */ 1226 /* check the duplicate "default" server for this address:port */
1224 1227
1225 if (lsopt->default_server) { 1228 if (lsopt->default_server) {
1226 1229
1227 if (addr[i].opt.default_server) { 1230 if (default_server) {
1228 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 1231 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1229 "a duplicate default server for %s", addr[i].opt.addr); 1232 "a duplicate default server for %s", addr[i].opt.addr);
1230 return NGX_ERROR; 1233 return NGX_ERROR;
1231 } 1234 }
1232 1235
1236 default_server = 1;
1233 addr[i].default_server = cscf; 1237 addr[i].default_server = cscf;
1234 } 1238 }
1239
1240 addr[i].opt.default_server = default_server;
1235 1241
1236 return NGX_OK; 1242 return NGX_OK;
1237 } 1243 }
1238 1244
1239 /* add the address to the addresses list that bound to this port */ 1245 /* add the address to the addresses list that bound to this port */