Klaus Demo nginx / c71e3d8
*) fix segfaults in types hash *) fix inheritance: default hash instead of inherited one Igor Sysoev 12 years ago
3 changed file(s) with 55 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
14831483 ngx_http_charset_recode_t *recode;
14841484 ngx_http_charset_main_conf_t *mcf;
14851485
1486 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
1487 prev->types_keys, &prev->types,
1488 ngx_http_charset_default_types)
1489 != NGX_OK)
1490 {
1491 return NGX_CONF_ERROR;
1492 }
1493
14861494 ngx_conf_merge_value(conf->override_charset, prev->override_charset, 0);
14871495 ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET);
14881496
15211529
15221530 recode->src = conf->source_charset;
15231531 recode->dst = conf->charset;
1524
1525 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types,
1526 prev->types_keys, &prev->types,
1527 ngx_http_charset_default_types)
1528 != NGX_OK)
1529 {
1530 return NGX_CONF_ERROR;
1531 }
15321532
15331533 return NGX_CONF_OK;
15341534 }
17601760
17611761 char *
17621762 ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, ngx_hash_t *types_hash,
1763 ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
1763 ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
17641764 ngx_str_t *default_types)
17651765 {
17661766 ngx_hash_init_t hash;
17671767
1768 if (keys == NULL) {
1769
1770 if (prev_keys) {
1771 *types_hash = *prev_types_hash;
1772 return NGX_CONF_OK;
1773 }
1774
1775 if (ngx_http_set_default_types(cf, &keys, default_types)
1776 != NGX_CONF_OK)
1777 {
1768 if (keys) {
1769
1770 hash.hash = types_hash;
1771 hash.key = NULL;
1772 hash.max_size = 2048;
1773 hash.bucket_size = 64;
1774 hash.name = "test_types_hash";
1775 hash.pool = cf->pool;
1776 hash.temp_pool = NULL;
1777
1778 if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
17781779 return NGX_CONF_ERROR;
17791780 }
1780 }
1781
1782 hash.hash = types_hash;
1783 hash.key = NULL;
1784 hash.max_size = 2048;
1785 hash.bucket_size = 64;
1786 hash.name = "test_types_hash";
1787 hash.pool = cf->pool;
1788 hash.temp_pool = NULL;
1789
1790 if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) {
1791 return NGX_CONF_ERROR;
1792 }
1781
1782 return NGX_CONF_OK;
1783 }
1784
1785 if (prev_types_hash->buckets == NULL) {
1786
1787 if (prev_keys == NULL) {
1788
1789 if (ngx_http_set_default_types(cf, &prev_keys, default_types)
1790 != NGX_OK)
1791 {
1792 return NGX_CONF_ERROR;
1793 }
1794 }
1795
1796 hash.hash = prev_types_hash;
1797 hash.key = NULL;
1798 hash.max_size = 2048;
1799 hash.bucket_size = 64;
1800 hash.name = "test_types_hash";
1801 hash.pool = cf->pool;
1802 hash.temp_pool = NULL;
1803
1804 if (ngx_hash_init(&hash, prev_keys->elts, prev_keys->nelts) != NGX_OK) {
1805 return NGX_CONF_ERROR;
1806 }
1807 }
1808
1809 *types_hash = *prev_types_hash;
17931810
17941811 return NGX_CONF_OK;
17951812
17961813 }
17971814
17981815
1799 char *
1816 ngx_int_t
18001817 ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
18011818 ngx_str_t *default_type)
18021819 {
18041821
18051822 *types = ngx_array_create(cf->temp_pool, 1, sizeof(ngx_hash_key_t));
18061823 if (*types == NULL) {
1807 return NGX_CONF_ERROR;
1824 return NGX_ERROR;
18081825 }
18091826
18101827 while (default_type->len) {
18111828
18121829 type = ngx_array_push(*types);
18131830 if (type == NULL) {
1814 return NGX_CONF_ERROR;
1831 return NGX_ERROR;
18151832 }
18161833
18171834 type->key = *default_type;
18221839 default_type++;
18231840 }
18241841
1825 return NGX_CONF_OK;
1826 }
1842 return NGX_OK;
1843 }
110110 char *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys,
111111 ngx_hash_t *types_hash, ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash,
112112 ngx_str_t *default_types);
113 char *ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
113 ngx_int_t ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
114114 ngx_str_t *default_type);
115115
116116