summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-09-12 23:05:01 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-09-13 03:37:40 -0400
commit062ea98bcbbfdf6056c55d127919cefed8a33722 (patch)
tree77e324f046e5537ee8757e8b3df9e716954b8498
parent7b615d5d24048d38bd7e8368dd1de91b0d26cbaa (diff)
downloadlighttpd-git-062ea98bcbbfdf6056c55d127919cefed8a33722.tar.gz
[multiple] prefer r->tmp_buf to p->tmp_buf
prefer per-request r->tmp_buf to per-module p->tmp_buf to marginally increase buf reuse during each request. (currently, r->tmp_buf == srv->tmp_buf) (avoid some persistent memory allocations per-module, as those are not currently cleared/released periodically)
-rw-r--r--src/mod_evhost.c4
-rw-r--r--src/mod_mysql_vhost.c5
-rw-r--r--src/mod_simple_vhost.c4
-rw-r--r--src/mod_vhostdb.c9
4 files changed, 5 insertions, 17 deletions
diff --git a/src/mod_evhost.c b/src/mod_evhost.c
index 2b3ca146..7266aa2d 100644
--- a/src/mod_evhost.c
+++ b/src/mod_evhost.c
@@ -34,7 +34,6 @@ typedef struct {
plugin_config defaults;
plugin_config conf;
- buffer tmp_buf;
array split_vals;
} plugin_data;
@@ -51,7 +50,6 @@ static void mod_evhost_free_path_pieces(const buffer *path_pieces) {
FREE_FUNC(mod_evhost_free) {
plugin_data * const p = p_d;
- free(p->tmp_buf.ptr);
array_free_data(&p->split_vals);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
@@ -335,7 +333,7 @@ static handler_t mod_evhost_uri_handler(request_st * const r, void *p_d) {
/* missing even default(global) conf */
if (NULL == p->conf.path_pieces) return HANDLER_GO_ON;
- buffer * const b = &p->tmp_buf;
+ buffer * const b = r->tmp_buf;/*(tmp_buf cleared before use in call below)*/
mod_evhost_build_doc_root_path(b, &p->split_vals, &r->uri.authority, p->conf.path_pieces);
if (!stat_cache_path_isdir(b)) {
diff --git a/src/mod_mysql_vhost.c b/src/mod_mysql_vhost.c
index 40a6375f..d9e72cd8 100644
--- a/src/mod_mysql_vhost.c
+++ b/src/mod_mysql_vhost.c
@@ -30,8 +30,6 @@ typedef struct {
PLUGIN_DATA;
plugin_config defaults;
plugin_config conf;
-
- buffer tmp_buf;
} plugin_data;
typedef struct {
@@ -46,7 +44,6 @@ INIT_FUNC(mod_mysql_vhost_init) {
/* cleanup the mysql connections */
FREE_FUNC(mod_mysql_vhost_cleanup) {
plugin_data * const p = p_d;
- free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@@ -291,7 +288,7 @@ REQUEST_FUNC(mod_mysql_vhost_handle_docroot) {
if (buffer_is_equal(c->server_name, &r->uri.authority)) goto GO_ON;
/* build and run SQL query */
- buffer * const b = &p->tmp_buf;
+ buffer * const b = r->tmp_buf;
buffer_clear(b);
for (const char *ptr = p->conf.mysql_query->ptr, *d; *ptr; ptr = d+1) {
if (NULL != (d = strchr(ptr, '?'))) {
diff --git a/src/mod_simple_vhost.c b/src/mod_simple_vhost.c
index fb0b845f..b497f7ce 100644
--- a/src/mod_simple_vhost.c
+++ b/src/mod_simple_vhost.c
@@ -22,7 +22,6 @@ typedef struct {
plugin_config defaults;
plugin_config conf;
- buffer tmp_buf;
buffer last_root;
} plugin_data;
@@ -32,7 +31,6 @@ INIT_FUNC(mod_simple_vhost_init) {
FREE_FUNC(mod_simple_vhost_free) {
plugin_data *p = p_d;
- free(p->tmp_buf.ptr);
free(p->last_root.ptr);
}
@@ -183,7 +181,7 @@ static handler_t mod_simple_vhost_docroot(request_st * const r, void *p_data) {
* are the two differences between mod_simple_vhost and mod_vhostdb) */
/* build document-root */
- buffer * const b = &p->tmp_buf;
+ buffer * const b = r->tmp_buf;/*(tmp_buf cleared before use in call below)*/
const buffer *host = &r->uri.authority;
if ((!buffer_is_blank(host) && build_doc_root(r, p, b, host))
|| build_doc_root(r, p, b, (host = p->conf.default_host))) {
diff --git a/src/mod_vhostdb.c b/src/mod_vhostdb.c
index 7f138d30..d6efee10 100644
--- a/src/mod_vhostdb.c
+++ b/src/mod_vhostdb.c
@@ -35,8 +35,6 @@ typedef struct {
PLUGIN_DATA;
plugin_config defaults;
plugin_config conf;
-
- buffer tmp_buf;
} plugin_data;
typedef struct {
@@ -134,7 +132,6 @@ INIT_FUNC(mod_vhostdb_init) {
FREE_FUNC(mod_vhostdb_free) {
plugin_data *p = p_d;
- free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
@@ -273,8 +270,6 @@ static handler_t mod_vhostdb_found (request_st * const r, vhostdb_cache_entry *
REQUEST_FUNC(mod_vhostdb_handle_docroot) {
plugin_data *p = p_d;
vhostdb_cache_entry *ve;
- const http_vhostdb_backend_t *backend;
- buffer *b;
/* no host specified? */
if (buffer_is_blank(&r->uri.authority)) return HANDLER_GO_ON;
@@ -291,8 +286,8 @@ REQUEST_FUNC(mod_vhostdb_handle_docroot) {
if (p->conf.vhostdb_cache && (ve = mod_vhostdb_cache_query(r, p)))
return mod_vhostdb_found(r, ve); /* HANDLER_GO_ON */
- b = &p->tmp_buf;
- backend = p->conf.vhostdb_backend;
+ buffer * const b = r->tmp_buf; /*(cleared before use in backend->query())*/
+ const http_vhostdb_backend_t * const backend = p->conf.vhostdb_backend;
if (0 != backend->query(r, backend->p_d, b)) {
return mod_vhostdb_error_500(r); /* HANDLER_FINISHED */
}