Mercurial > hg > nginx
comparison src/http/ngx_http.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | 70e1c7d2b83d |
children | 117ccc7c4055 |
comparison
equal
deleted
inserted
replaced
289:0750faf8d7e3 | 290:87e73f067470 |
---|---|
44 }; | 44 }; |
45 | 45 |
46 | 46 |
47 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 47 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
48 { | 48 { |
49 int mi, m, s, l, p, a, n; | 49 ngx_uint_t mi, m, s, l, p, a, n; |
50 int port_found, addr_found, virtual_names; | 50 ngx_uint_t port_found, addr_found, virtual_names; |
51 char *rv; | 51 char *rv; |
52 struct sockaddr_in *addr_in; | 52 struct sockaddr_in *addr_in; |
53 ngx_conf_t pcf; | 53 ngx_conf_t pcf; |
54 ngx_array_t in_ports; | 54 ngx_array_t in_ports; |
55 ngx_listening_t *ls; | 55 ngx_listening_t *ls; |
302 /* | 302 /* |
303 * check duplicate "default" server that | 303 * check duplicate "default" server that |
304 * serves this address:port | 304 * serves this address:port |
305 */ | 305 */ |
306 | 306 |
307 if (lscf[l].flags & NGX_HTTP_DEFAULT_SERVER) { | 307 if (lscf[l].default_server) { |
308 if (in_addr[a].flags | 308 if (in_addr[a].default_server) { |
309 & NGX_HTTP_DEFAULT_SERVER) { | |
310 | |
311 ngx_log_error(NGX_LOG_ERR, cf->log, 0, | 309 ngx_log_error(NGX_LOG_ERR, cf->log, 0, |
312 "duplicate default server in %s:%d", | 310 "duplicate default server in %s:%d", |
313 lscf[l].file_name.data, | 311 lscf[l].file_name.data, |
314 lscf[l].line); | 312 lscf[l].line); |
315 | 313 |
316 return NGX_CONF_ERROR; | 314 return NGX_CONF_ERROR; |
317 } | 315 } |
318 | 316 |
319 in_addr[a].flags |= NGX_HTTP_DEFAULT_SERVER; | |
320 in_addr[a].core_srv_conf = cscfp[s]; | 317 in_addr[a].core_srv_conf = cscfp[s]; |
318 in_addr[a].default_server = 1; | |
321 } | 319 } |
322 | 320 |
323 addr_found = 1; | 321 addr_found = 1; |
324 | 322 |
325 break; | 323 break; |
338 | 336 |
339 ngx_memcpy(inaddr, &in_addr[a], | 337 ngx_memcpy(inaddr, &in_addr[a], |
340 sizeof(ngx_http_in_addr_t)); | 338 sizeof(ngx_http_in_addr_t)); |
341 | 339 |
342 in_addr[a].addr = lscf[l].addr; | 340 in_addr[a].addr = lscf[l].addr; |
343 in_addr[a].flags = lscf[l].flags; | 341 in_addr[a].default_server = lscf[l].default_server; |
344 in_addr[a].core_srv_conf = cscfp[s]; | 342 in_addr[a].core_srv_conf = cscfp[s]; |
345 | 343 |
346 /* | 344 /* |
347 * create the empty list of the server names that | 345 * create the empty list of the server names that |
348 * can be served on this address:port | 346 * can be served on this address:port |
368 ngx_test_null(inaddr, | 366 ngx_test_null(inaddr, |
369 ngx_push_array(&in_port[p].addrs), | 367 ngx_push_array(&in_port[p].addrs), |
370 NGX_CONF_ERROR); | 368 NGX_CONF_ERROR); |
371 | 369 |
372 inaddr->addr = lscf[l].addr; | 370 inaddr->addr = lscf[l].addr; |
373 inaddr->flags = lscf[l].flags; | 371 inaddr->default_server = lscf[l].default_server; |
374 inaddr->core_srv_conf = cscfp[s]; | 372 inaddr->core_srv_conf = cscfp[s]; |
375 | 373 |
376 /* | 374 /* |
377 * create the empty list of the server names that | 375 * create the empty list of the server names that |
378 * can be served on this address:port | 376 * can be served on this address:port |
395 | 393 |
396 in_port->port = lscf[l].port; | 394 in_port->port = lscf[l].port; |
397 | 395 |
398 ngx_test_null(in_port->port_name.data, ngx_palloc(cf->pool, 7), | 396 ngx_test_null(in_port->port_name.data, ngx_palloc(cf->pool, 7), |
399 NGX_CONF_ERROR); | 397 NGX_CONF_ERROR); |
400 in_port->port_name.len = ngx_snprintf(in_port->port_name.data, | 398 in_port->port_name.len = ngx_snprintf((char *) |
399 in_port->port_name.data, | |
401 7, ":%d", | 400 7, ":%d", |
402 in_port->port); | 401 in_port->port); |
403 | 402 |
404 /* create list of the addresses that bound to this port ... */ | 403 /* create list of the addresses that bound to this port ... */ |
405 | 404 |
411 NGX_CONF_ERROR); | 410 NGX_CONF_ERROR); |
412 | 411 |
413 /* ... and add the address to this list */ | 412 /* ... and add the address to this list */ |
414 | 413 |
415 inaddr->addr = lscf[l].addr; | 414 inaddr->addr = lscf[l].addr; |
416 inaddr->flags = lscf[l].flags; | 415 inaddr->default_server = lscf[l].default_server; |
417 inaddr->core_srv_conf = cscfp[s]; | 416 inaddr->core_srv_conf = cscfp[s]; |
418 | 417 |
419 /* | 418 /* |
420 * create the empty list of the server names that | 419 * create the empty list of the server names that |
421 * can be served on this address:port | 420 * can be served on this address:port |
493 ngx_test_null(ls->addr_text.data, | 492 ngx_test_null(ls->addr_text.data, |
494 ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6), | 493 ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6), |
495 NGX_CONF_ERROR); | 494 NGX_CONF_ERROR); |
496 | 495 |
497 ls->addr_text.len = | 496 ls->addr_text.len = |
498 ngx_snprintf(ls->addr_text.data | 497 ngx_snprintf((char *) ls->addr_text.data |
499 + ngx_inet_ntop(AF_INET, | 498 + ngx_inet_ntop(AF_INET, |
500 (char *) &in_addr[a].addr, | 499 (u_char *) |
500 &in_addr[a].addr, | |
501 ls->addr_text.data, | 501 ls->addr_text.data, |
502 INET_ADDRSTRLEN), | 502 INET_ADDRSTRLEN), |
503 6, ":%d", in_port[p].port); | 503 6, ":%d", in_port[p].port); |
504 | 504 |
505 ls->fd = -1; | 505 ls->fd = (ngx_socket_t) -1; |
506 ls->family = AF_INET; | 506 ls->family = AF_INET; |
507 ls->type = SOCK_STREAM; | 507 ls->type = SOCK_STREAM; |
508 ls->protocol = IPPROTO_IP; | 508 ls->protocol = IPPROTO_IP; |
509 #if (WIN32) | 509 #if (WIN32) |
510 ls->flags = WSA_FLAG_OVERLAPPED; | 510 ls->flags = WSA_FLAG_OVERLAPPED; |
594 for (p = 0; p < in_ports.nelts; p++) { | 594 for (p = 0; p < in_ports.nelts; p++) { |
595 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, | 595 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, |
596 "port: %d %08x", in_port[p].port, &in_port[p]); | 596 "port: %d %08x", in_port[p].port, &in_port[p]); |
597 in_addr = in_port[p].addrs.elts; | 597 in_addr = in_port[p].addrs.elts; |
598 for (a = 0; a < in_port[p].addrs.nelts; a++) { | 598 for (a = 0; a < in_port[p].addrs.nelts; a++) { |
599 char ip[20]; | 599 u_char ip[20]; |
600 ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20); | 600 ngx_inet_ntop(AF_INET, (u_char *) &in_addr[a].addr, ip, 20); |
601 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, | 601 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, |
602 "%s %08x", ip, in_addr[a].core_srv_conf); | 602 "%s %08x", ip, in_addr[a].core_srv_conf); |
603 s_name = in_addr[a].names.elts; | 603 s_name = in_addr[a].names.elts; |
604 for (n = 0; n < in_addr[a].names.nelts; n++) { | 604 for (n = 0; n < in_addr[a].names.nelts; n++) { |
605 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, | 605 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, |