comparison src/http/ngx_http.c @ 238:674f85a4d00f

nginx-0.0.1-2004-01-23-12:26:18 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 23 Jan 2004 09:26:18 +0000
parents 86e473b5641e
children b6793bc5034b
comparison
equal deleted inserted replaced
237:8d5cce3ae221 238:674f85a4d00f
241 cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), 241 cf->cycle->pool, 10, sizeof(ngx_http_handler_pt),
242 NGX_CONF_ERROR); 242 NGX_CONF_ERROR);
243 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK; 243 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK;
244 244
245 245
246 /* create the lists of the ports, the addresses and the server names 246 /*
247 to allow quickly find the server core module configuration at run-time */ 247 * create the lists of the ports, the addresses and the server names
248 * to allow quickly find the server core module configuration at run-time
249 */
248 250
249 ngx_init_array(in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t), 251 ngx_init_array(in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t),
250 NGX_CONF_ERROR); 252 NGX_CONF_ERROR);
251 253
252 /* "server" directives */ 254 /* "server" directives */
280 282
281 /* "server_name" directives */ 283 /* "server_name" directives */
282 s_name = cscfp[s]->server_names.elts; 284 s_name = cscfp[s]->server_names.elts;
283 for (n = 0; n < cscfp[s]->server_names.nelts; n++) { 285 for (n = 0; n < cscfp[s]->server_names.nelts; n++) {
284 286
285 /* add the server name and server core module 287 /*
286 configuration to the address:port */ 288 * add the server name and server core module
289 * configuration to the address:port
290 */
287 291
288 /* TODO: duplicate names can be checked here */ 292 /* TODO: duplicate names can be checked here */
289 293
290 ngx_test_null(name, 294 ngx_test_null(name,
291 ngx_push_array(&in_addr[a].names), 295 ngx_push_array(&in_addr[a].names),
293 297
294 name->name = s_name[n].name; 298 name->name = s_name[n].name;
295 name->core_srv_conf = s_name[n].core_srv_conf; 299 name->core_srv_conf = s_name[n].core_srv_conf;
296 } 300 }
297 301
298 /* check duplicate "default" server that 302 /*
299 serves this address:port */ 303 * check duplicate "default" server that
304 * serves this address:port
305 */
300 306
301 if (lscf[l].flags & NGX_HTTP_DEFAULT_SERVER) { 307 if (lscf[l].flags & NGX_HTTP_DEFAULT_SERVER) {
302 if (in_addr[a].flags 308 if (in_addr[a].flags
303 & NGX_HTTP_DEFAULT_SERVER) { 309 & NGX_HTTP_DEFAULT_SERVER) {
304 310
318 324
319 break; 325 break;
320 326
321 } else if (in_addr[a].addr == INADDR_ANY) { 327 } else if (in_addr[a].addr == INADDR_ANY) {
322 328
323 /* "*:port" must be the last resort so move it 329 /*
324 to the end of the address list and add 330 * "*:port" must be the last resort so move it
325 the new address at its place */ 331 * to the end of the address list and add
332 * the new address at its place
333 */
326 334
327 ngx_test_null(inaddr, 335 ngx_test_null(inaddr,
328 ngx_push_array(&in_port[p].addrs), 336 ngx_push_array(&in_port[p].addrs),
329 NGX_CONF_ERROR); 337 NGX_CONF_ERROR);
330 338
333 341
334 in_addr[a].addr = lscf[l].addr; 342 in_addr[a].addr = lscf[l].addr;
335 in_addr[a].flags = lscf[l].flags; 343 in_addr[a].flags = lscf[l].flags;
336 in_addr[a].core_srv_conf = cscfp[s]; 344 in_addr[a].core_srv_conf = cscfp[s];
337 345
338 /* create the empty list of the server names that 346 /*
339 can be served on this address:port */ 347 * create the empty list of the server names that
348 * can be served on this address:port
349 */
340 350
341 ngx_init_array(inaddr->names, cf->pool, 10, 351 ngx_init_array(inaddr->names, cf->pool, 10,
342 sizeof(ngx_http_server_name_t), 352 sizeof(ngx_http_server_name_t),
343 NGX_CONF_ERROR); 353 NGX_CONF_ERROR);
344 354
348 } 358 }
349 } 359 }
350 360
351 if (!addr_found) { 361 if (!addr_found) {
352 362
353 /* add the address to the addresses list that 363 /*
354 bound to this port */ 364 * add the address to the addresses list that
365 * bound to this port
366 */
355 367
356 ngx_test_null(inaddr, 368 ngx_test_null(inaddr,
357 ngx_push_array(&in_port[p].addrs), 369 ngx_push_array(&in_port[p].addrs),
358 NGX_CONF_ERROR); 370 NGX_CONF_ERROR);
359 371
360 inaddr->addr = lscf[l].addr; 372 inaddr->addr = lscf[l].addr;
361 inaddr->flags = lscf[l].flags; 373 inaddr->flags = lscf[l].flags;
362 inaddr->core_srv_conf = cscfp[s]; 374 inaddr->core_srv_conf = cscfp[s];
363 375
364 /* create the empty list of the server names that 376 /*
365 can be served on this address:port */ 377 * create the empty list of the server names that
378 * can be served on this address:port
379 */
366 380
367 ngx_init_array(inaddr->names, cf->pool, 10, 381 ngx_init_array(inaddr->names, cf->pool, 10,
368 sizeof(ngx_http_server_name_t), 382 sizeof(ngx_http_server_name_t),
369 NGX_CONF_ERROR); 383 NGX_CONF_ERROR);
370 } 384 }
400 414
401 inaddr->addr = lscf[l].addr; 415 inaddr->addr = lscf[l].addr;
402 inaddr->flags = lscf[l].flags; 416 inaddr->flags = lscf[l].flags;
403 inaddr->core_srv_conf = cscfp[s]; 417 inaddr->core_srv_conf = cscfp[s];
404 418
405 /* create the empty list of the server names that 419 /*
406 can be served on this address:port */ 420 * create the empty list of the server names that
421 * can be served on this address:port
422 */
407 423
408 ngx_init_array(inaddr->names, cf->pool, 10, 424 ngx_init_array(inaddr->names, cf->pool, 10,
409 sizeof(ngx_http_server_name_t), 425 sizeof(ngx_http_server_name_t),
410 NGX_CONF_ERROR); 426 NGX_CONF_ERROR);
411 } 427 }
432 virtual_names = 1; 448 virtual_names = 1;
433 break; 449 break;
434 } 450 }
435 } 451 }
436 452
437 /* if the all server names point to the same server 453 /*
438 then we do not need to check them at run-time */ 454 * if the all server names point to the same server
455 * then we do not need to check them at run-time
456 */
439 457
440 if (!virtual_names) { 458 if (!virtual_names) {
441 in_addr[a].names.nelts = 0; 459 in_addr[a].names.nelts = 0;
442 } 460 }
443 } 461 }
444 462
445 /* if there's the binding to "*:port" then we need to bind() 463 /*
446 to "*:port" only and ignore the other bindings */ 464 * if there's the binding to "*:port" then we need to bind()
465 * to "*:port" only and ignore the other bindings
466 */
447 467
448 if (in_addr[a - 1].addr == INADDR_ANY) { 468 if (in_addr[a - 1].addr == INADDR_ANY) {
449 a--; 469 a--;
450 470
451 } else { 471 } else {
520 if (in_port[p].addrs.nelts > 1) { 540 if (in_port[p].addrs.nelts > 1) {
521 541
522 in_addr = in_port[p].addrs.elts; 542 in_addr = in_port[p].addrs.elts;
523 if (in_addr[in_port[p].addrs.nelts - 1].addr != INADDR_ANY) { 543 if (in_addr[in_port[p].addrs.nelts - 1].addr != INADDR_ANY) {
524 544
525 /* if this port has not the "*:port" binding then create 545 /*
526 the separate ngx_http_in_port_t for the all bindings */ 546 * if this port has not the "*:port" binding then create
547 * the separate ngx_http_in_port_t for the all bindings
548 */
527 549
528 ngx_test_null(inport, 550 ngx_test_null(inport,
529 ngx_palloc(cf->pool, 551 ngx_palloc(cf->pool,
530 sizeof(ngx_http_in_port_t)), 552 sizeof(ngx_http_in_port_t)),
531 NGX_CONF_ERROR); 553 NGX_CONF_ERROR);