diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-05-03 22:18:20 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-05-06 17:35:00 -0400 |
commit | 9a5e1652bef3d392b0b698eda1dafbfa771a1f92 (patch) | |
tree | 772aa94b2ea9c6f51caa18640d7d8ee5ff252b83 /src/mod_staticfile.c | |
parent | 7ff6adc44c498f465cf247da03a44a6717fc1502 (diff) | |
download | lighttpd-git-9a5e1652bef3d392b0b698eda1dafbfa771a1f92.tar.gz |
[multiple] static file optimization; reuse cache
reuse cache lookup in common case of serving a static file
rather than repeating the stat_cache_entry lookup
(which is more work than memcmp() to re-check stat_cache_entry match)
Diffstat (limited to 'src/mod_staticfile.c')
-rw-r--r-- | src/mod_staticfile.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mod_staticfile.c b/src/mod_staticfile.c index 036fac64..3dd5e5ab 100644 --- a/src/mod_staticfile.c +++ b/src/mod_staticfile.c @@ -7,6 +7,7 @@ #include "plugin.h" #include "response.h" +#include "stat_cache.h" #include <stdlib.h> #include <string.h> @@ -99,10 +100,10 @@ SETDEFAULTS_FUNC(mod_staticfile_set_defaults) { URIHANDLER_FUNC(mod_staticfile_subrequest) { plugin_data * const p = p_d; - if (r->http_status != 0) return HANDLER_GO_ON; - if (buffer_is_empty(&r->physical.path)) return HANDLER_GO_ON; if (NULL != r->handler_module) return HANDLER_GO_ON; if (!http_method_get_head_post(r->http_method)) return HANDLER_GO_ON; + /* r->physical.path is non-empty for handle_subrequest_start */ + /*if (buffer_string_is_empty(&r->physical.path)) return HANDLER_GO_ON;*/ mod_staticfile_patch_config(r, p); @@ -127,7 +128,14 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) { } if (!p->conf.etags_used) r->conf.etag_flags = 0; - http_response_send_file(r, &r->physical.path); + + /* r->tmp_sce is set in http_response_physical_path_check() and is valid + * in handle_subrequest_start callback -- handle_subrequest_start callbacks + * should not change r->physical.path (or should invalidate r->tmp_sce) */ + if (r->tmp_sce && !buffer_is_equal(&r->tmp_sce->name, &r->physical.path)) + r->tmp_sce = NULL; + + http_response_send_file(r, &r->physical.path, r->tmp_sce); return HANDLER_FINISHED; } |