Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_core_module.c @ 454:a8424ffa495c NGINX_0_7_39
nginx 0.7.39
*) Bugfix: large response with SSI might hang, if gzipping was enabled;
the bug had appeared in 0.7.28.
Thanks to Artem Bokhan.
*) Bugfix: a segmentation fault might occur in worker process, if short
static variants are used in a "try_files" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 02 Mar 2009 00:00:00 +0300 |
parents | 20962db0117c |
children | ca8f7f6cab16 |
comparison
equal
deleted
inserted
replaced
453:9ef0e36f3cd5 | 454:a8424ffa495c |
---|---|
1084 | 1084 |
1085 } else { | 1085 } else { |
1086 len = tf->name.len; | 1086 len = tf->name.len; |
1087 } | 1087 } |
1088 | 1088 |
1089 reserve = len - r->uri.len; | |
1090 | |
1091 /* 16 bytes are preallocation */ | 1089 /* 16 bytes are preallocation */ |
1092 reserve = reserve < 16 ? 16 : reserve + 16; | 1090 reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16; |
1093 | |
1094 reserve += alias; | |
1095 | 1091 |
1096 if (reserve > allocated) { | 1092 if (reserve > allocated) { |
1097 | 1093 |
1098 /* we just need to allocate path and to copy a root */ | 1094 /* we just need to allocate path and to copy a root */ |
1099 | 1095 |
1553 | 1549 |
1554 if (c >= 'A' && c <= 'Z') { | 1550 if (c >= 'A' && c <= 'Z') { |
1555 | 1551 |
1556 exten = ngx_pnalloc(r->pool, r->exten.len); | 1552 exten = ngx_pnalloc(r->pool, r->exten.len); |
1557 if (exten == NULL) { | 1553 if (exten == NULL) { |
1558 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1554 return NGX_ERROR; |
1559 } | 1555 } |
1560 | 1556 |
1561 hash = ngx_hash_strlow(exten, r->exten.data, r->exten.len); | 1557 hash = ngx_hash_strlow(exten, r->exten.data, r->exten.len); |
1562 | 1558 |
1563 r->exten.data = exten; | 1559 r->exten.data = exten; |
1682 == NULL) | 1678 == NULL) |
1683 { | 1679 { |
1684 return NULL; | 1680 return NULL; |
1685 } | 1681 } |
1686 | 1682 |
1687 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0)== NGX_ERROR) | 1683 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0) != NGX_OK) { |
1688 { | |
1689 return NULL; | 1684 return NULL; |
1690 } | 1685 } |
1691 | 1686 |
1692 *root_length = path->len - reserved; | 1687 *root_length = path->len - reserved; |
1693 last = path->data + *root_length; | 1688 last = path->data + *root_length; |
1774 ngx_int_t | 1769 ngx_int_t |
1775 ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s) | 1770 ngx_http_server_addr(ngx_http_request_t *r, ngx_str_t *s) |
1776 { | 1771 { |
1777 socklen_t len; | 1772 socklen_t len; |
1778 ngx_connection_t *c; | 1773 ngx_connection_t *c; |
1779 struct sockaddr_in *sin; | |
1780 u_char sa[NGX_SOCKADDRLEN]; | 1774 u_char sa[NGX_SOCKADDRLEN]; |
1781 | 1775 |
1782 c = r->connection; | 1776 c = r->connection; |
1783 | 1777 |
1784 if (c->local_sockaddr == NULL) { | 1778 if (c->local_sockaddr == NULL) { |
1796 } | 1790 } |
1797 | 1791 |
1798 c->local_socklen = len; | 1792 c->local_socklen = len; |
1799 ngx_memcpy(c->local_sockaddr, &sa, len); | 1793 ngx_memcpy(c->local_sockaddr, &sa, len); |
1800 } | 1794 } |
1801 | |
1802 sin = (struct sockaddr_in *) c->local_sockaddr; | |
1803 r->in_addr = sin->sin_addr.s_addr; | |
1804 | 1795 |
1805 if (s == NULL) { | 1796 if (s == NULL) { |
1806 return NGX_OK; | 1797 return NGX_OK; |
1807 } | 1798 } |
1808 | 1799 |
2008 return NGX_ERROR; | 1999 return NGX_ERROR; |
2009 } | 2000 } |
2010 | 2001 |
2011 if (ngx_list_init(&sr->headers_out.headers, r->pool, 20, | 2002 if (ngx_list_init(&sr->headers_out.headers, r->pool, 20, |
2012 sizeof(ngx_table_elt_t)) | 2003 sizeof(ngx_table_elt_t)) |
2013 == NGX_ERROR) | 2004 != NGX_OK) |
2014 { | 2005 { |
2015 return NGX_ERROR; | 2006 return NGX_ERROR; |
2016 } | 2007 } |
2017 | 2008 |
2018 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 2009 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
2062 sr->write_event_handler = ngx_http_handler; | 2053 sr->write_event_handler = ngx_http_handler; |
2063 | 2054 |
2064 if (c->data == r && r->postponed == NULL) { | 2055 if (c->data == r && r->postponed == NULL) { |
2065 c->data = sr; | 2056 c->data = sr; |
2066 } | 2057 } |
2067 | |
2068 sr->in_addr = r->in_addr; | |
2069 sr->port = r->port; | |
2070 sr->port_text = r->port_text; | |
2071 | 2058 |
2072 sr->variables = r->variables; | 2059 sr->variables = r->variables; |
2073 | 2060 |
2074 sr->log_handler = r->log_handler; | 2061 sr->log_handler = r->log_handler; |
2075 | 2062 |
2600 value = cf->args->elts; | 2587 value = cf->args->elts; |
2601 | 2588 |
2602 if (ngx_strcmp(value[0].data, "include") == 0) { | 2589 if (ngx_strcmp(value[0].data, "include") == 0) { |
2603 file = value[1]; | 2590 file = value[1]; |
2604 | 2591 |
2605 if (ngx_conf_full_name(cf->cycle, &file, 1) == NGX_ERROR){ | 2592 if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) { |
2606 return NGX_CONF_ERROR; | 2593 return NGX_CONF_ERROR; |
2607 } | 2594 } |
2608 | 2595 |
2609 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data); | 2596 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data); |
2610 | 2597 |
2734 * conf->client_large_buffers.num = 0; | 2721 * conf->client_large_buffers.num = 0; |
2735 */ | 2722 */ |
2736 | 2723 |
2737 if (ngx_array_init(&cscf->listen, cf->temp_pool, 4, | 2724 if (ngx_array_init(&cscf->listen, cf->temp_pool, 4, |
2738 sizeof(ngx_http_listen_t)) | 2725 sizeof(ngx_http_listen_t)) |
2739 == NGX_ERROR) | 2726 != NGX_OK) |
2740 { | 2727 { |
2741 return NGX_CONF_ERROR; | 2728 return NGX_CONF_ERROR; |
2742 } | 2729 } |
2743 | 2730 |
2744 if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4, | 2731 if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4, |
2745 sizeof(ngx_http_server_name_t)) | 2732 sizeof(ngx_http_server_name_t)) |
2746 == NGX_ERROR) | 2733 != NGX_OK) |
2747 { | 2734 { |
2748 return NGX_CONF_ERROR; | 2735 return NGX_CONF_ERROR; |
2749 } | 2736 } |
2750 | 2737 |
2751 cscf->connection_pool_size = NGX_CONF_UNSET_SIZE; | 2738 cscf->connection_pool_size = NGX_CONF_UNSET_SIZE; |
2960 | 2947 |
2961 if (prev->root.data == NULL) { | 2948 if (prev->root.data == NULL) { |
2962 conf->root.len = sizeof("html") - 1; | 2949 conf->root.len = sizeof("html") - 1; |
2963 conf->root.data = (u_char *) "html"; | 2950 conf->root.data = (u_char *) "html"; |
2964 | 2951 |
2965 if (ngx_conf_full_name(cf->cycle, &conf->root, 0) == NGX_ERROR) { | 2952 if (ngx_conf_full_name(cf->cycle, &conf->root, 0) != NGX_OK) { |
2966 return NGX_CONF_ERROR; | 2953 return NGX_CONF_ERROR; |
2967 } | 2954 } |
2968 } | 2955 } |
2969 } | 2956 } |
2970 | 2957 |
3532 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') { | 3519 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') { |
3533 lcf->root.len--; | 3520 lcf->root.len--; |
3534 } | 3521 } |
3535 | 3522 |
3536 if (lcf->root.data[0] != '$') { | 3523 if (lcf->root.data[0] != '$') { |
3537 if (ngx_conf_full_name(cf->cycle, &lcf->root, 0) == NGX_ERROR) { | 3524 if (ngx_conf_full_name(cf->cycle, &lcf->root, 0) != NGX_OK) { |
3538 return NGX_CONF_ERROR; | 3525 return NGX_CONF_ERROR; |
3539 } | 3526 } |
3540 } | 3527 } |
3541 | 3528 |
3542 n = ngx_http_script_variables_count(&lcf->root); | 3529 n = ngx_http_script_variables_count(&lcf->root); |