summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2023-04-20 19:06:58 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2023-05-03 23:11:35 -0400
commitb706546c77b8eaabcb5102a2440c91505b2a1914 (patch)
tree5c671f51697b134d8c6b50034d4c8c01d2e2ba71 /src
parentfd142a53ebab66e6d2057a84485a1812499e9410 (diff)
downloadlighttpd-git-b706546c77b8eaabcb5102a2440c91505b2a1914.tar.gz
[mod_cgi] comment about caching target dirname
comment code about caching target dirname using stat_cache In simple performance tests, using stat_cache here makes little difference, as the overhead of process creation is orders of magnitude larger.
Diffstat (limited to 'src')
-rw-r--r--src/mod_cgi.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mod_cgi.c b/src/mod_cgi.c
index a4839837..f47448cc 100644
--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -985,7 +985,24 @@ static int cgi_create_env(request_st * const r, plugin_data * const p, handler_c
fdevent_createprocess(args, envp, (intptr_t)to_cgi_fds[0],
(intptr_t)from_cgi_fds[1], serrh_fd, dfd);
#else
+ #if 0 /*(if cache used, then must skip fdio_close_dirfd(dfd) further below)*/
+ /*(similar to fdevent_open_dirname(), but leveraging stat_cache)*/
+ /*(would need specialized routine to also pass O_DIRECTORY)*/
+ /*(if not for r->conf.follow_symlink policy (of dubious benefit itself),
+ * the target dir could be handled in fdevent_fork_execve() similarly
+ * to how target dir is handled in fdevent_createprocess())*/
+ /*(handle special cases of no dirname or dirname is root directory)*/
+ const char * const path = r->physical.path.ptr;
+ char * const c = strrchr(path, '/');
+ const char * const dname = (NULL != c ? c != path ? path : "/" : ".");
+ buffer * const tb = r->tmp_buf;
+ buffer_copy_string_len(tb, dname, dname == path ? (uint32_t)(c - path) : 1);
+ const stat_cache_entry * const sce =
+ stat_cache_get_entry_open(tb, r->conf.follow_symlink);
+ int dfd = sce ? sce->fd : -1;
+ #else
int dfd = fdevent_open_dirname(r->physical.path.ptr,r->conf.follow_symlink);
+ #endif
if (-1 == dfd) {
log_perror(r->conf.errh, __FILE__, __LINE__, "open dirname %s failed", r->physical.path.ptr);
}