forked from openwrt/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
h2o: Do not initialize the mime types map at startup
The map takes a fair amount of memory and the only consumer of this library, dnsdist, does not need it. Signed-off-by: Remi Gacogne <[email protected]>
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- a/lib/core/config.c | ||
+++ b/lib/core/config.c | ||
@@ -1,3 +1,4 @@ | ||
+ | ||
/* | ||
* Copyright (c) 2014-2016 DeNA Co., Ltd. | ||
* | ||
@@ -37,7 +38,9 @@ static h2o_hostconf_t *create_hostconf(h | ||
hostconf->http2.push_preload = 1; /* enabled by default */ | ||
h2o_config_init_pathconf(&hostconf->fallback_path, globalconf, NULL, globalconf->mimemap); | ||
hostconf->mimemap = globalconf->mimemap; | ||
- h2o_mem_addref_shared(hostconf->mimemap); | ||
+ if (hostconf->mimemap) { | ||
+ h2o_mem_addref_shared(hostconf->mimemap); | ||
+ } | ||
return hostconf; | ||
} | ||
|
||
@@ -54,7 +57,9 @@ static void destroy_hostconf(h2o_hostcon | ||
} | ||
free(hostconf->paths.entries); | ||
h2o_config_dispose_pathconf(&hostconf->fallback_path); | ||
- h2o_mem_release_shared(hostconf->mimemap); | ||
+ if (hostconf->mimemap) { | ||
+ h2o_mem_release_shared(hostconf->mimemap); | ||
+ } | ||
|
||
free(hostconf); | ||
} | ||
@@ -136,8 +141,10 @@ void h2o_config_init_pathconf(h2o_pathco | ||
h2o_chunked_register(pathconf); | ||
if (path != NULL) | ||
pathconf->path = h2o_strdup(NULL, path, SIZE_MAX); | ||
- h2o_mem_addref_shared(mimemap); | ||
- pathconf->mimemap = mimemap; | ||
+ if (mimemap) { | ||
+ h2o_mem_addref_shared(mimemap); | ||
+ pathconf->mimemap = mimemap; | ||
+ } | ||
pathconf->error_log.emit_request_errors = 1; | ||
} | ||
|
||
@@ -190,7 +197,7 @@ void h2o_config_init(h2o_globalconf_t *c | ||
config->http2.latency_optimization.max_additional_delay = 10; | ||
config->http2.latency_optimization.max_cwnd = 65535; | ||
config->http2.callbacks = H2O_HTTP2_CALLBACKS; | ||
- config->mimemap = h2o_mimemap_create(); | ||
+ // config->mimemap = h2o_mimemap_create(); | ||
|
||
h2o_configurator__init_core(config); | ||
} | ||
@@ -279,7 +286,9 @@ void h2o_config_dispose(h2o_globalconf_t | ||
} | ||
free(config->hosts); | ||
|
||
- h2o_mem_release_shared(config->mimemap); | ||
+ if (config->mimemap) { | ||
+ h2o_mem_release_shared(config->mimemap); | ||
+ } | ||
h2o_configurator__dispose_configurators(config); | ||
} | ||
|
||
--- a/lib/core/request.c | ||
+++ b/lib/core/request.c | ||
@@ -486,7 +486,7 @@ void h2o_req_fill_mime_attributes(h2o_re | ||
ssize_t content_type_index; | ||
h2o_mimemap_type_t *mime; | ||
|
||
- if (req->res.mime_attr != NULL) | ||
+ if (req->res.mime_attr != NULL || req->pathconf->mimemap == NULL) | ||
return; | ||
|
||
if ((content_type_index = h2o_find_header(&req->res.headers, H2O_TOKEN_CONTENT_TYPE, -1)) != -1 && |