summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2018-11-23 00:37:38 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2018-11-23 00:37:38 -0500
commitf69bd9cdb89f7288c982fafe550cc8f1297d08ca (patch)
treeea66c7a21cda103eb6b34c6672df8957a8c371c8
parent9749503b1dc221aed4ba6e215c6acb893d8281be (diff)
downloadlighttpd-git-f69bd9cdb89f7288c982fafe550cc8f1297d08ca.tar.gz
[core] perf: simple, quick buffer_clear()
quickly clear buffer instead of buffer_string_set_length(b, 0) or buffer_reset(b). Avoids free() of large buffers about to be reused, or buffers that are module-scoped, persistent, and reused. (buffer_reset() should still be used with buffers in connection *con when the data in the buffers is supplied by external, untrusted source)
-rw-r--r--src/buffer.h11
-rw-r--r--src/chunk.c6
-rw-r--r--src/configfile-glue.c2
-rw-r--r--src/configfile.c5
-rw-r--r--src/configparser.y2
-rw-r--r--src/connections-glue.c6
-rw-r--r--src/connections.c13
-rw-r--r--src/data_config.c6
-rw-r--r--src/data_integer.c2
-rw-r--r--src/etag.c3
-rw-r--r--src/gw_backend.c6
-rw-r--r--src/http-header-glue.c10
-rw-r--r--src/http_chunk.c2
-rw-r--r--src/keyvalue.c2
-rw-r--r--src/log.c2
-rw-r--r--src/mod_accesslog.c12
-rw-r--r--src/mod_authn_ldap.c4
-rw-r--r--src/mod_cgi.c2
-rw-r--r--src/mod_cml.c12
-rw-r--r--src/mod_cml_lua.c2
-rw-r--r--src/mod_compress.c8
-rw-r--r--src/mod_deflate.c4
-rw-r--r--src/mod_dirlisting.c4
-rw-r--r--src/mod_evhost.c2
-rw-r--r--src/mod_expire.c2
-rw-r--r--src/mod_extforward.c6
-rw-r--r--src/mod_fastcgi.c6
-rw-r--r--src/mod_magnet.c2
-rw-r--r--src/mod_mysql_vhost.c2
-rw-r--r--src/mod_proxy.c2
-rw-r--r--src/mod_scgi.c6
-rw-r--r--src/mod_ssi.c2
-rw-r--r--src/mod_uploadprogress.c2
-rw-r--r--src/mod_userdir.c2
-rw-r--r--src/mod_vhostdb_dbi.c4
-rw-r--r--src/mod_vhostdb_ldap.c6
-rw-r--r--src/mod_vhostdb_mysql.c6
-rw-r--r--src/mod_vhostdb_pgsql.c4
-rw-r--r--src/mod_webdav.c6
-rw-r--r--src/mod_wstunnel.c16
-rw-r--r--src/network.c2
-rw-r--r--src/plugin.c1
-rw-r--r--src/response.c4
-rw-r--r--src/server.c8
-rw-r--r--src/stat_cache.c6
45 files changed, 110 insertions, 113 deletions
diff --git a/src/buffer.h b/src/buffer.h
index fa887094..60ea5c4a 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -65,6 +65,13 @@ void buffer_commit(buffer *b, size_t size);
*/
void buffer_string_set_length(buffer *b, size_t len);
+/* clear buffer
+ * - invalidate buffer contents
+ * - unsets used chars but does not modify existing ptr contents
+ * (b->ptr *is not* set to an empty, '\0'-terminated string "")
+ */
+static inline void buffer_clear(buffer *b);
+
void buffer_copy_string(buffer *b, const char *s);
void buffer_copy_string_len(buffer *b, const char *s, size_t s_len);
void buffer_copy_buffer(buffer *b, const buffer *src);
@@ -206,4 +213,8 @@ static inline void buffer_append_slash(buffer *b) {
if (len > 0 && '/' != b->ptr[len-1]) BUFFER_APPEND_STRING_CONST(b, "/");
}
+static inline void buffer_clear(buffer *b) {
+ b->used = 0;
+}
+
#endif
diff --git a/src/chunk.c b/src/chunk.c
index 4d55a3de..4489a854 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -99,7 +99,7 @@ static void chunk_reset_file_chunk(chunk *c) {
static void chunk_reset(chunk *c) {
if (c->type == FILE_CHUNK) chunk_reset_file_chunk(c);
- buffer_string_set_length(c->mem, 0);
+ buffer_clear(c->mem);
c->offset = 0;
}
@@ -134,7 +134,7 @@ void chunk_buffer_release(buffer *b) {
c->mem = b;
c->next = chunks;
chunks = c;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
}
else {
buffer_free(b);
@@ -426,7 +426,7 @@ void chunkqueue_use_memory(chunkqueue *cq, size_t len) {
/* unused buffer: can't remove chunk easily from
* end of list, so just reset the buffer
*/
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
}
}
diff --git a/src/configfile-glue.c b/src/configfile-glue.c
index af93673e..94c8909a 100644
--- a/src/configfile-glue.c
+++ b/src/configfile-glue.c
@@ -430,7 +430,7 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat
break;
case COMP_HTTP_REQUEST_METHOD:
l = srv->tmp_buf;
- buffer_string_set_length(l, 0);
+ buffer_clear(l);
http_method_append(l, con->request.http_method);
break;
default:
diff --git a/src/configfile.c b/src/configfile.c
index 916c8534..9a2b7f18 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -1445,7 +1445,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
pid_t wpid;
int wstatus;
buffer *out = srv->tmp_buf;
- buffer_string_set_length(out, 0);
+ buffer_clear(out);
close(fds[1]);
fds[1] = -1;
do {
@@ -1592,11 +1592,10 @@ int config_set_defaults(server *srv) {
if (srv->srvconf.upload_tempdirs->used) {
buffer * const b = srv->tmp_buf;
size_t len;
+ buffer_clear(b);
if (!buffer_string_is_empty(srv->srvconf.changeroot)) {
buffer_copy_buffer(b, srv->srvconf.changeroot);
buffer_append_slash(b);
- } else {
- buffer_reset(b);
}
len = buffer_string_length(b);
diff --git a/src/configparser.y b/src/configparser.y
index 2d7a3ba2..e7b67ef5 100644
--- a/src/configparser.y
+++ b/src/configparser.y
@@ -53,7 +53,7 @@ static data_unset *configparser_get_variable(config_t *ctx, const buffer *key) {
#endif
if (NULL != (du = array_get_element_klen(dc->value, CONST_BUF_LEN(key)))) {
du = du->fn->copy(du);
- buffer_reset(du->key);
+ buffer_clear(du->key);
return du;
}
}
diff --git a/src/connections-glue.c b/src/connections-glue.c
index b1db56de..8b4f9712 100644
--- a/src/connections-glue.c
+++ b/src/connections-glue.c
@@ -494,11 +494,11 @@ void connection_response_reset(server *srv, connection *con) {
con->file_started = 0;
con->response.keep_alive = 0;
if (con->physical.path) { /*(skip for mod_fastcgi authorizer)*/
- buffer_reset(con->physical.doc_root);
+ buffer_clear(con->physical.doc_root);
buffer_reset(con->physical.path);
- buffer_reset(con->physical.basedir);
+ buffer_clear(con->physical.basedir);
buffer_reset(con->physical.rel_path);
- buffer_reset(con->physical.etag);
+ buffer_clear(con->physical.etag);
}
con->response.htags = 0;
array_reset_data_strings(con->response.headers);
diff --git a/src/connections.c b/src/connections.c
index 63b2c429..4c8d6a3e 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -610,7 +610,7 @@ int connection_reset(server *srv, connection *con) {
con->request.http_version = HTTP_VERSION_UNSET;
#define CLEAN(x) \
- if (con->x) buffer_reset(con->x);
+ buffer_reset(con->x);
CLEAN(request.uri);
CLEAN(request.request_line);
@@ -631,16 +631,7 @@ int connection_reset(server *srv, connection *con) {
/*CLEAN(proto);*//* set to default in connection_accepted() */
#undef CLEAN
-#define CLEAN(x) \
- if (con->x) con->x->used = 0;
-
-#undef CLEAN
-
-#define CLEAN(x) \
- con->request.x = NULL;
-
- CLEAN(http_host);
-#undef CLEAN
+ con->request.http_host = NULL;
con->request.content_length = 0;
con->request.te_chunked = 0;
con->request.htags = 0;
diff --git a/src/data_config.c b/src/data_config.c
index f005b1b3..764dc600 100644
--- a/src/data_config.c
+++ b/src/data_config.c
@@ -49,9 +49,9 @@ static void data_config_reset(data_unset *d) {
data_config *ds = (data_config *)d;
/* reused array elements */
- buffer_reset(ds->key);
- buffer_reset(ds->comp_tag);
- buffer_reset(ds->comp_key);
+ buffer_clear(ds->key);
+ buffer_clear(ds->comp_tag);
+ buffer_clear(ds->comp_key);
array_reset(ds->value);
}
diff --git a/src/data_integer.c b/src/data_integer.c
index 3d5536fc..020acdc2 100644
--- a/src/data_integer.c
+++ b/src/data_integer.c
@@ -28,7 +28,7 @@ static void data_integer_reset(data_unset *d) {
data_integer *ds = (data_integer *)d;
/* reused integer elements */
- buffer_reset(ds->key);
+ buffer_clear(ds->key);
ds->value = 0;
}
diff --git a/src/etag.c b/src/etag.c
index 99600c27..7aab2bbb 100644
--- a/src/etag.c
+++ b/src/etag.c
@@ -146,7 +146,7 @@ int etag_is_equal(buffer *etag, const char *line, int weak_ok) {
int etag_create(buffer *etag, struct stat *st,etag_flags_t flags) {
if (0 == flags) return 0;
- buffer_reset(etag);
+ buffer_clear(etag);
if (flags & ETAG_USE_INODE) {
buffer_append_int(etag, st->st_ino);
@@ -172,7 +172,6 @@ int etag_mutate(buffer *mut, buffer *etag) {
len = buffer_string_length(etag);
for (h=0, i=0; i < len; ++i) h = (h<<5)^(h>>27)^(etag->ptr[i]);
- buffer_reset(mut);
buffer_copy_string_len(mut, CONST_STR_LEN("\""));
buffer_append_int(mut, h);
buffer_append_string_len(mut, CONST_STR_LEN("\""));
diff --git a/src/gw_backend.c b/src/gw_backend.c
index e4bc2012..0c44ebdd 100644
--- a/src/gw_backend.c
+++ b/src/gw_backend.c
@@ -1113,7 +1113,7 @@ static void handler_ctx_clear(gw_handler_ctx *hctx) {
if (hctx->wb) chunkqueue_reset(hctx->wb);
hctx->wb_reqlen = 0;
- if (hctx->response) buffer_string_set_length(hctx->response, 0);
+ if (hctx->response) buffer_clear(hctx->response);
hctx->fd = -1;
hctx->fde_ndx = -1;
@@ -1279,7 +1279,7 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, data_unset *du, size
}
host = gw_host_init();
- buffer_reset(gw_mode);
+ buffer_clear(gw_mode);
buffer_copy_buffer(host->id, da_host->key);
@@ -2377,7 +2377,7 @@ handler_t gw_check_extension(server *srv, connection *con, gw_plugin_data *p, in
if (host->fix_root_path_name && extension->key->ptr[0] == '/'
&& extension->key->ptr[1] == '\0'){
buffer_copy_buffer(con->request.pathinfo, con->uri.path);
- buffer_string_set_length(con->uri.path, 0);
+ buffer_clear(con->uri.path);
} else if (extension->key->ptr[0] == '/'
&& buffer_string_length(con->uri.path)
> buffer_string_length(extension->key)
diff --git a/src/http-header-glue.c b/src/http-header-glue.c
index be8df872..cb07f56a 100644
--- a/src/http-header-glue.c
+++ b/src/http-header-glue.c
@@ -98,7 +98,7 @@ buffer * strftime_cache_get(server *srv, time_t last_mod) {
srv->mtime_cache[i].mtime = last_mod;
tm = gmtime(&(srv->mtime_cache[i].mtime));
- buffer_string_set_length(srv->mtime_cache[i].str, 0);
+ buffer_clear(srv->mtime_cache[i].str);
buffer_append_strftime(srv->mtime_cache[i].str, "%a, %d %b %Y %H:%M:%S GMT", tm);
return srv->mtime_cache[i].str;
@@ -1103,7 +1103,7 @@ handler_t http_response_parse_headers(server *srv, connection *con, http_respons
&& NULL != (vb = http_header_response_get(con, HTTP_HEADER_OTHER, CONST_STR_LEN("X-Sendfile2")))) {
http_response_xsendfile2(srv, con, vb, opts->xsendfile_docroot);
/* http_header_response_unset() shortcut for HTTP_HEADER_OTHER */
- buffer_reset(vb); /*(do not send to client)*/
+ buffer_clear(vb); /*(do not send to client)*/
if (con->mode == DIRECT) con->file_started = 0;
return HANDLER_FINISHED;
} else if (NULL != (vb = http_header_response_get(con, HTTP_HEADER_OTHER, CONST_STR_LEN("X-Sendfile")))
@@ -1111,7 +1111,7 @@ handler_t http_response_parse_headers(server *srv, connection *con, http_respons
&& NULL != (vb = http_header_response_get(con, HTTP_HEADER_OTHER, CONST_STR_LEN("X-LIGHTTPD-send-file"))))) {
http_response_xsendfile(srv, con, vb, opts->xsendfile_docroot);
/* http_header_response_unset() shortcut for HTTP_HEADER_OTHER */
- buffer_reset(vb); /*(do not send to client)*/
+ buffer_clear(vb); /*(do not send to client)*/
if (con->mode == DIRECT) con->file_started = 0;
return HANDLER_FINISHED;
}
@@ -1224,14 +1224,14 @@ handler_t http_response_read(server *srv, connection *con, http_response_opts *o
handler_t rc = http_response_parse_headers(srv, con, opts, b);
if (rc != HANDLER_GO_ON) return rc;
/* accumulate response in b until headers completed (or error) */
- if (con->file_started) buffer_string_set_length(b, 0);
+ if (con->file_started) buffer_clear(b);
} else {
if (0 != http_chunk_append_buffer(srv, con, b)) {
/* error writing to tempfile;
* truncate response or send 500 if nothing sent yet */
return HANDLER_ERROR;
}
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
}
if ((con->conf.stream_response_body & FDEVENT_STREAM_RESPONSE_BUFMIN)
diff --git a/src/http_chunk.c b/src/http_chunk.c
index 3c620773..1bdf2fa8 100644
--- a/src/http_chunk.c
+++ b/src/http_chunk.c
@@ -23,7 +23,7 @@
#include <string.h>
static buffer * http_chunk_header(buffer *b, uintmax_t len) {
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
buffer_append_uint_hex(b, len);
buffer_append_string_len(b, CONST_STR_LEN("\r\n"));
return b;
diff --git a/src/keyvalue.c b/src/keyvalue.c
index 0b19ea1e..c1b6b019 100644
--- a/src/keyvalue.c
+++ b/src/keyvalue.c
@@ -270,7 +270,7 @@ static void pcre_keyvalue_buffer_subst(buffer *b, const buffer *patternb, const
/* search for $... or %... pattern substitutions */
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
for (size_t k = 0; k + 1 < pattern_len; ++k) {
if (pattern[k] == '$' || pattern[k] == '%') {
diff --git a/src/log.c b/src/log.c
index 8b50190c..866ade39 100644
--- a/src/log.c
+++ b/src/log.c
@@ -123,7 +123,7 @@ static int log_buffer_prepare(buffer *b, server *srv, const char *filename, unsi
if (-1 == srv->errorlog_fd) return -1;
/* cache the generated timestamp */
if (srv->cur_ts != srv->last_generated_debug_ts) {
- buffer_string_set_length(srv->ts_debug_str, 0);
+ buffer_clear(srv->ts_debug_str);
buffer_append_strftime(srv->ts_debug_str, "%Y-%m-%d %H:%M:%S", localtime(&(srv->cur_ts)));
srv->last_generated_debug_ts = srv->cur_ts;
diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c
index 9c6182dd..5a64cf1d 100644
--- a/src/mod_accesslog.c
+++ b/src/mod_accesslog.c
@@ -679,7 +679,7 @@ static void log_access_flush(server *srv, void *p_d) {
accesslog_write_all(srv, s->access_logfile, s->log_access_fd, CONST_BUF_LEN(s->access_logbuffer));
}
- buffer_reset(s->access_logbuffer);
+ buffer_clear(s->access_logbuffer);
}
}
}
@@ -781,10 +781,6 @@ REQUESTDONE_FUNC(log_access_write) {
b = p->conf.access_logbuffer;
}
- if (buffer_is_empty(b)) {
- buffer_string_set_length(b, 0);
- }
-
for (j = 0; j < p->conf.parsed_format->used; j++) {
const format_field * const f = p->conf.parsed_format->ptr[j];
switch(f->type) {
@@ -882,7 +878,7 @@ REQUESTDONE_FUNC(log_access_write) {
# endif /* HAVE_GMTIME_R */
#endif /* HAVE_STRUCT_TM_GMTOFF */
- buffer_string_set_length(p->conf.ts_accesslog_str, 0);
+ buffer_clear(p->conf.ts_accesslog_str);
if (buffer_string_is_empty(f->string)) {
#if defined(HAVE_STRUCT_TM_GMTOFF)
@@ -1131,9 +1127,9 @@ REQUESTDONE_FUNC(log_access_write) {
if (!buffer_string_is_empty(b)) {
/*(syslog appends a \n on its own)*/
syslog(p->conf.syslog_level, "%s", b->ptr);
- buffer_reset(b);
}
#endif
+ buffer_clear(b);
return HANDLER_GO_ON;
}
@@ -1145,7 +1141,7 @@ REQUESTDONE_FUNC(log_access_write) {
if (p->conf.log_access_fd >= 0) {
accesslog_write_all(srv, p->conf.access_logfile, p->conf.log_access_fd, CONST_BUF_LEN(b));
}
- buffer_reset(b);
+ buffer_clear(b);
}
return HANDLER_GO_ON;
diff --git a/src/mod_authn_ldap.c b/src/mod_authn_ldap.c
index feda6ed3..233fc239 100644
--- a/src/mod_authn_ldap.c
+++ b/src/mod_authn_ldap.c
@@ -93,7 +93,7 @@ static void mod_authn_add_scheme (server *srv, buffer *host)
"ldap://", "ldaps://", "ldapi://", "cldap://"
};
char *b, *e = host->ptr;
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
while (*(b = e)) {
unsigned int j;
while (*b==' '||*b=='\t'||*b=='\r'||*b=='\n'||*b==',') ++b;
@@ -611,7 +611,7 @@ static handler_t mod_authn_ldap_basic(server *srv, connection *con, void *p_d, c
}
/* build filter to get DN for uid = username */
- buffer_string_set_length(p->ldap_filter, 0);
+ buffer_clear(p->ldap_filter);
if (*template->ptr == ',') {
/* special-case filter template beginning with ',' to be explicit DN */
buffer_append_string_len(p->ldap_filter, CONST_STR_LEN("uid="));
diff --git a/src/mod_cgi.c b/src/mod_cgi.c
index 3ee7c2b4..aeec06f9 100644
--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -425,7 +425,7 @@ static int cgi_recv_response(server *srv, handler_ctx *hctx) {
return HANDLER_FINISHED;
case HANDLER_COMEBACK:
/* hctx->conf.local_redir */
- buffer_string_set_length(hctx->response, 0);
+ buffer_clear(hctx->response);
connection_response_reset(srv, hctx->remote_conn); /*(includes con->http_status = 0)*/
plugins_call_connection_reset(srv, hctx->remote_conn);
/*cgi_connection_close(srv, hctx);*//*(already cleaned up and hctx is now invalid)*/
diff --git a/src/mod_cml.c b/src/mod_cml.c
index 647c4dc6..c82a4c27 100644
--- a/src/mod_cml.c
+++ b/src/mod_cml.c
@@ -231,9 +231,9 @@ URIHANDLER_FUNC(mod_cml_power_magnet) {
mod_cml_patch_connection(srv, con, p);
- buffer_reset(p->basedir);
- buffer_reset(p->baseurl);
- buffer_reset(p->trigger_handler);
+ buffer_clear(p->basedir);
+ buffer_clear(p->baseurl);
+ buffer_clear(p->trigger_handler);
if (buffer_string_is_empty(p->conf.power_magnet)) return HANDLER_GO_ON;
@@ -285,9 +285,9 @@ URIHANDLER_FUNC(mod_cml_is_handled) {
mod_cml_patch_connection(srv, con, p);
- buffer_reset(p->basedir);
- buffer_reset(p->baseurl);
- buffer_reset(p->trigger_handler);
+ buffer_clear(p->basedir);
+ buffer_clear(p->baseurl);
+ buffer_clear(p->trigger_handler);
if (buffer_string_is_empty(p->conf.ext)) return HANDLER_GO_ON;
diff --git a/src/mod_cml_lua.c b/src/mod_cml_lua.c
index 2036d127..7f6901e2 100644
--- a/src/mod_cml_lua.c
+++ b/src/mod_cml_lua.c
@@ -162,7 +162,7 @@ int cache_parse_lua(server *srv, connection *con, plugin_data *p, buffer *fn) {
buffer_copy_buffer(b, con->uri.query);
cache_export_get_params(L, get_tbl, b);
- buffer_reset(b);
+ buffer_clear(b);
}
lua_setglobal(L, "get");
diff --git a/src/mod_compress.c b/src/mod_compress.c
index 9f297330..dc8babcd 100644
--- a/src/mod_compress.c
+++ b/src/mod_compress.c
@@ -204,7 +204,7 @@ SETDEFAULTS_FUNC(mod_compress_setdefaults) {
cv[2].destination = &(s->compress_max_filesize);
cv[3].destination = encodings_arr; /* temp array for allowed encodings list */
cv[4].destination = srv->tmp_buf;
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
p->config_storage[i] = s;
@@ -889,13 +889,17 @@ PHYSICALPATH_FUNC(mod_compress_physical) {
/* check if mimetype is in compress-config */
content_type = NULL;
stat_cache_content_type_get(srv, con, con->physical.path, sce);
- if (sce->content_type->ptr) {
+ if (!buffer_is_empty(sce->content_type)) {
char *c;
if ( (c = strchr(sce->content_type->ptr, ';')) != NULL) {
content_type = srv->tmp_buf;
buffer_copy_string_len(content_type, sce->content_type->ptr, c - sce->content_type->ptr);
}
}
+ else {
+ content_type = srv->tmp_buf;
+ buffer_copy_string_len(content_type, CONST_STR_LEN(""));
+ }
for (m = 0; m < p->conf.compress->used; m++) {
data_string *compress_ds = (data_string *)p->conf.compress->data[m];
diff --git a/src/mod_deflate.c b/src/mod_deflate.c
index 0a4a70b4..d7a7ea95 100644
--- a/src/mod_deflate.c
+++ b/src/mod_deflate.c
@@ -308,7 +308,7 @@ SETDEFAULTS_FUNC(mod_deflate_setdefaults) {
cv[5].destination = &(s->output_buffer_size);
cv[6].destination = &(s->work_block_size);
cv[7].destination = p->tmp_buf;
- buffer_string_set_length(p->tmp_buf, 0);
+ buffer_clear(p->tmp_buf);
p->config_storage[i] = s;
@@ -1184,7 +1184,7 @@ CONNECTION_FUNC(mod_deflate_handle_response_start) {
hctx->plugin_data = p;
hctx->compression_type = compression_type;
/* setup output buffer */
- buffer_string_set_length(p->tmp_buf, 0);
+ buffer_clear(p->tmp_buf);
hctx->output = p->tmp_buf;
if (0 != mod_deflate_stream_init(hctx)) {
/*(should not happen unless ENOMEM)*/
diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c
index 11304007..5c492a95 100644
--- a/src/mod_dirlisting.c
+++ b/src/mod_dirlisting.c
@@ -326,7 +326,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
buffer_copy_string_len(s->show_readme, CONST_STR_LEN("README.txt"));
}
else if (buffer_is_equal_string(s->show_readme, CONST_STR_LEN("disable"))) {
- buffer_string_set_length(s->show_readme, 0);
+ buffer_clear(s->show_readme);
}
}
@@ -335,7 +335,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) {
buffer_copy_string_len(s->show_header, CONST_STR_LEN("HEADER.txt"));
}
else if (buffer_is_equal_string(s->show_header, CONST_STR_LEN("disable"))) {
- buffer_string_set_length(s->show_header, 0);
+ buffer_clear(s->show_header);
}
}
}
diff --git a/src/mod_evhost.c b/src/mod_evhost.c
index 52482dcb..891f28c0 100644
--- a/src/mod_evhost.c
+++ b/src/mod_evhost.c
@@ -294,7 +294,7 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d)
mod_evhost_parse_host(con, parsed_host, p->tmp_buf);
/* build document-root */
- buffer_reset(p->tmp_buf);
+ buffer_clear(p->tmp_buf);
for (i = 0; i < p->conf.len; i++) {
ptr = p->conf.path_pieces[i]->ptr;
diff --git a/src/mod_expire.c b/src/mod_expire.c
index bf61abde..221bb537 100644
--- a/src/mod_expire.c
+++ b/src/mod_expire.c
@@ -387,7 +387,7 @@ CONNECTION_FUNC(mod_expire_handler) {
/* expires should be at least srv->cur_ts */
if (expires < srv->cur_ts) expires = srv->cur_ts;
- buffer_string_set_length(p->expire_tstmp, 0);
+ buffer_clear(p->expire_tstmp);
buffer_append_strftime(p->expire_tstmp, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(expires)));
/* HTTP/1.0 */
diff --git a/src/mod_extforward.c b/src/mod_extforward.c
index ee9386b7..1493e16b 100644
--- a/src/mod_extforward.c
+++ b/src/mod_extforward.c
@@ -239,7 +239,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
if (NULL != nm_slash) {
log_error_write(srv, __FILE__, __LINE__, "sbsbs", "ERROR: untrusted CIDR masks are ignored (\"", ds->key, "\" => \"", ds->value, "\")");
}
- buffer_reset(ds->value); /* empty is untrusted */
+ buffer_clear(ds->value); /* empty is untrusted */
continue;
}
if (NULL != nm_slash) {
@@ -266,7 +266,7 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) {
rc = sock_addr_from_str_numeric(srv, &sm->addr, ds->key->ptr);
*nm_slash = '/';
if (1 != rc) return HANDLER_ERROR;
- buffer_reset(ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */
+ buffer_clear(ds->value); /* empty is untrusted, e.g. if subnet (incorrectly) appears in X-Forwarded-For */
}
}
}
@@ -964,7 +964,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
/* create X-Forwarded-For if not present
* (and at least original connecting IP is a trusted proxy) */
buffer *xff = srv->tmp_buf;
- buffer_string_set_length(xff, 0);
+ buffer_clear(xff);
for (j = 0; j < used; ) {
if (-1 == offsets[j]) { ++j; continue; }
if (3 == offsets[j+1]
diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c
index b3fb2e49..972668cb 100644
--- a/src/mod_fastcgi.c
+++ b/src/mod_fastcgi.c
@@ -254,7 +254,7 @@ static handler_t fcgi_create_env(server *srv, handler_ctx *hctx) {
if (0 != http_cgi_headers(srv, con, &opts, fcgi_env_add, b)) {
con->http_status = 400;
con->mode = DIRECT;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
chunkqueue_remove_finished_chunks(hctx->wb);
return HANDLER_FINISHED;
} else {
@@ -387,7 +387,7 @@ static handler_t fcgi_recv_parse(server *srv, connection *con, struct http_respo
buffer *hdrs = hctx->response;
if (NULL == hdrs) {
hdrs = srv->tmp_buf;
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
}
fastcgi_get_packet_body(hdrs, hctx, &packet);
if (HANDLER_GO_ON != http_response_parse_headers(srv, con, &hctx->opts, hdrs)) {
@@ -420,7 +420,7 @@ static handler_t fcgi_recv_parse(server *srv, connection *con, struct http_respo
case FCGI_STDERR:
if (packet.len == 0) break;
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
fastcgi_get_packet_body(srv->tmp_buf, hctx, &packet);
log_error_write_multiline_buffer(srv, __FILE__, __LINE__, srv->tmp_buf, "s",
"FastCGI-stderr:");
diff --git a/src/mod_magnet.c b/src/mod_magnet.c
index 1f9223a0..dcb1fd8c 100644
--- a/src/mod_magnet.c
+++ b/src/mod_magnet.c
@@ -538,7 +538,7 @@ static buffer *magnet_env_get_buffer_by_id(server *srv, connection *con, int id)
case MAGNET_ENV_URI_QUERY: dest = con->uri.query; break;
case MAGNET_ENV_REQUEST_METHOD:
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
http_method_append(srv->tmp_buf, con->request.http_method);
dest = srv->tmp_buf;
break;
diff --git a/src/mod_mysql_vhost.c b/src/mod_mysql_vhost.c
index 4739a184..2af5cc2b 100644
--- a/src/mod_mysql_vhost.c
+++ b/src/mod_mysql_vhost.c
@@ -290,7 +290,7 @@ CONNECTION_FUNC(mod_mysql_vhost_handle_docroot) {
if (buffer_is_equal(c->server_name, con->uri.authority)) goto GO_ON;
/* build and run SQL query */
- buffer_string_set_length(p->tmp_buf, 0);
+ buffer_clear(p->tmp_buf);
for (char *b = p->conf.mysql_query->ptr, *d; *b; b = d+1) {
if (NULL != (d = strchr(b, '?'))) {
/* escape the uri.authority */
diff --git a/src/mod_proxy.c b/src/mod_proxy.c
index ee9b4328..e4bd453b 100644
--- a/src/mod_proxy.c
+++ b/src/mod_proxy.c
@@ -536,7 +536,7 @@ static void proxy_set_Forwarded(connection *con, const unsigned int flags) {
CONST_STR_LEN("Forwarded"),
CONST_STR_LEN("x")); /*(must not be blank for _get below)*/
b = http_header_request_get(con, HTTP_HEADER_FORWARDED, CONST_STR_LEN("Forwarded"));
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
if (NULL != xff) {
/* use X-Forwarded-For contents to seed Forwarded */
char *s = xff->ptr;
diff --git a/src/mod_scgi.c b/src/mod_scgi.c
index bc40ee7b..00f53cf7 100644
--- a/src/mod_scgi.c
+++ b/src/mod_scgi.c
@@ -172,7 +172,7 @@ static handler_t scgi_create_env(server *srv, handler_ctx *hctx) {
if (0 != http_cgi_headers(srv, con, &opts, scgi_env_add, b)) {
con->http_status = 400;
con->mode = DIRECT;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
chunkqueue_remove_finished_chunks(hctx->wb);
return HANDLER_FINISHED;
}
@@ -180,7 +180,7 @@ static handler_t scgi_create_env(server *srv, handler_ctx *hctx) {
if (hctx->conf.proto == LI_PROTOCOL_SCGI) {
size_t len;
scgi_env_add(b, CONST_STR_LEN("SCGI"), CONST_STR_LEN("1"));
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
buffer_append_int(srv->tmp_buf, buffer_string_length(b)-10);
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN(":"));
len = buffer_string_length(srv->tmp_buf);
@@ -194,7 +194,7 @@ static handler_t scgi_create_env(server *srv, handler_ctx *hctx) {
if (len > USHRT_MAX) {
con->http_status = 431; /* Request Header Fields Too Large */
con->mode = DIRECT;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
chunkqueue_remove_finished_chunks(hctx->wb);
return HANDLER_FINISHED;
}
diff --git a/src/mod_ssi.c b/src/mod_ssi.c
index 0259fabc..cc032ee3 100644
--- a/src/mod_ssi.c
+++ b/src/mod_ssi.c
@@ -718,7 +718,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const
if (p->if_is_false) break;
b = srv->tmp_buf;
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
for (i = 0; i < p->ssi_vars->used; i++) {
data_string *ds = (data_string *)p->ssi_vars->data[p->ssi_vars->sorted[i]];
diff --git a/src/mod_uploadprogress.c b/src/mod_uploadprogress.c
index 9a1375a5..3dbd61e1 100644
--- a/src/mod_uploadprogress.c
+++ b/src/mod_uploadprogress.c
@@ -131,7 +131,7 @@ static int connection_map_remove_connection(connection_map *cm, connection *con)
if (cme->con == con) {
/* found connection */
- buffer_reset(cme->con_id);
+ buffer_clear(cme->con_id);
cme->con = NULL;
cm->used--;
diff --git a/src/mod_userdir.c b/src/mod_userdir.c
index 00cb5ffd..cf99cc03 100644
--- a/src/mod_userdir.c
+++ b/src/mod_userdir.c
@@ -330,7 +330,7 @@ URIHANDLER_FUNC(mod_userdir_docroot_handler) {
}
buffer_copy_buffer(con->physical.path, p->temp_path);
- buffer_reset(p->temp_path);
+ buffer_clear(p->temp_path);
return HANDLER_GO_ON;
}
diff --git a/src/mod_vhostdb_dbi.c b/src/mod_vhostdb_dbi.c
index bf58ab69..fbb60393 100644
--- a/src/mod_vhostdb_dbi.c
+++ b/src/mod_vhostdb_dbi.c
@@ -169,7 +169,7 @@ static int mod_vhostdb_dbi_query(server *srv, connection *con, void *p_d, buffer
/*(reuse buffer for sql query before generating docroot result)*/
buffer *sqlquery = docroot;
- buffer_string_set_length(sqlquery, 0); /*(also resets docroot (alias))*/
+ buffer_clear(sqlquery); /*(also resets docroot (alias))*/
mod_vhostdb_patch_connection(srv, con, p);
if (NULL == p->conf.vdata) return 0; /*(after resetting docroot)*/
@@ -198,7 +198,7 @@ static int mod_vhostdb_dbi_query(server *srv, connection *con, void *p_d, buffer
result = dbi_conn_query(dbconf->dbconn, sqlquery->ptr);
} while (!result && ++retry_count < 2);
- buffer_string_set_length(docroot, 0); /*(reset buffer to store result)*/
+ buffer_clear(docroot); /*(reset buffer to store result)*/
if (!result) {
const char *errmsg;
diff --git a/src/mod_vhostdb_ldap.c b/src/mod_vhostdb_ldap.c
index 57a5ee26..e21e1c26 100644
--- a/src/mod_vhostdb_ldap.c
+++ b/src/mod_vhostdb_ldap.c
@@ -57,7 +57,7 @@ static void mod_vhostdb_dbconf_add_scheme (server *srv, buffer *host)
"ldap://", "ldaps://", "ldapi://", "cldap://"
};
char *b, *e = host->ptr;
- buffer_string_set_length(srv->tmp_buf, 0);
+ buffer_clear(srv->tmp_buf);
while (*(b = e)) {
unsigned int j;
while (*b==' '||*b=='\t'||*b=='\r'||*b=='\n'||*b==',') ++b;
@@ -381,7 +381,7 @@ static int mod_vhostdb_ldap_query(server *srv, connection *con, void *p_d, buffe
/*(reuse buffer for ldap query before generating docroot result)*/
buffer *filter = docroot;
- buffer_string_set_length(filter, 0); /*(also resets docroot (alias))*/
+ buffer_clear(filter); /*(also resets docroot (alias))*/
mod_vhostdb_patch_connection(srv, con, p);
if (NULL == p->conf.vdata) return 0; /*(after resetting docroot)*/
@@ -419,7 +419,7 @@ static int mod_vhostdb_ldap_query(server *srv, connection *con, void *p_d, buffe
"you might have to refine the filter:", filter);
}
- buffer_string_set_length(docroot, 0); /*(reset buffer to store result)*/
+ buffer_clear(docroot); /*(reset buffer to store result)*/
if (0 == count) { /*(no entries found)*/
ldap_msgfree(lm);
diff --git a/src/mod_vhostdb_mysql.c b/src/mod_vhostdb_mysql.c
index 6f53ca8d..bd3d63a2 100644
--- a/src/mod_vhostdb_mysql.c
+++ b/src/mod_vhostdb_mysql.c
@@ -133,7 +133,7 @@ static int mod_vhostdb_mysql_query(server *srv, connection *con, void *p_d, buff
/*(reuse buffer for sql query before generating docroot result)*/
buffer *sqlquery = docroot;
- buffer_string_set_length(sqlquery, 0); /*(also resets docroot (alias))*/
+ buffer_clear(sqlquery); /*(also resets docroot (alias))*/
mod_vhostdb_patch_connection(srv, con, p);
if (NULL == p->conf.vdata) return 0; /*(after resetting docroot)*/
@@ -160,11 +160,11 @@ static int mod_vhostdb_mysql_query(server *srv, connection *con, void *p_d, buff
if (mysql_real_query(dbconf->dbconn, CONST_BUF_LEN(sqlquery))) {
log_error_write(srv, __FILE__, __LINE__, "s",
mysql_error(dbconf->dbconn));
- buffer_string_set_length(docroot, 0); /*(reset buffer; no result)*/
+ buffer_clear(docroot); /*(reset buffer; no result)*/
return -1;
}
- buffer_string_set_length(docroot, 0); /*(reset buffer to store result)*/
+ buffer_clear(docroot); /*(reset buffer to store result)*/
result = mysql_store_result(dbconf->dbconn);
cols = mysql_num_fields(result);
diff --git a/src/mod_vhostdb_pgsql.c b/src/mod_vhostdb_pgsql.c
index 5d33c604..5dd2b458 100644
--- a/src/mod_vhostdb_pgsql.c
+++ b/src/mod_vhostdb_pgsql.c
@@ -111,7 +111,7 @@ static int mod_vhostdb_pgsql_query(server *srv, connection *con, void *p_d, buff
/*(reuse buffer for sql query before generating docroot result)*/
buffer *sqlquery = docroot;
- buffer_string_set_length(sqlquery, 0); /*(also resets docroot (alias))*/
+ buffer_clear(sqlquery); /*(also resets docroot (alias))*/
mod_vhostdb_patch_connection(srv, con, p);
if (NULL == p->conf.vdata) return 0; /*(after resetting docroot)*/
@@ -138,7 +138,7 @@ static int mod_vhostdb_pgsql_query(server *srv, connection *con, void *p_d, buff
res = PQexec(dbconf->dbconn, sqlquery->ptr);
- buffer_string_set_length(docroot, 0); /*(reset buffer to store result)*/
+ buffer_clear(docroot); /*(reset buffer to store result)*/
if (PGRES_TUPLES_OK != PQresultStatus(res)) {
log_error_write(srv, __FILE__, __LINE__, "s",
diff --git a/src/mod_webdav.c b/src/mod_webdav.c
index eda8cb38..41212a8f 100644
--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -983,7 +983,7 @@ static int webdav_get_live_property(server *srv, connection *con, handler_ctx *h
buffer_append_string_len(b, CONST_STR_LEN("<D:getetag>"));
buffer_append_string_buffer(b, con->physical.etag);
buffer_append_string_len(b, CONST_STR_LEN("</D:getetag>"));
- buffer_reset(con->physical.etag);
+ buffer_clear(con->physical.etag);
found = 1;
#ifdef USE_LOCKS
} else if (0 == strcmp(prop_name, "lockdiscovery")) {
@@ -1527,8 +1527,8 @@ SUBREQUEST_FUNC(mod_webdav_subrequest_handler_huge) {
buffer_append_string(d.path, de->d_name);
buffer_append_string(d.rel_path, de->d_name);
- buffer_reset(prop_200);
- buffer_reset(prop_404);
+ buffer_clear(prop_200);
+ buffer_clear(prop_404);
webdav_get_props(srv, con, hctx, &d, req_props, prop_200, prop_404);
diff --git a/src/mod_wstunnel.c b/src/mod_wstunnel.c
index 12fe5eb2..8051e8a7 100644
--- a/src/mod_wstunnel.c
+++ b/src/mod_wstunnel.c
@@ -274,7 +274,7 @@ SETDEFAULTS_FUNC(mod_wstunnel_set_defaults) {
if (!buffer_is_empty(s->frame_type)
&& !buffer_is_equal_caseless_string(s->frame_type,
CONST_STR_LEN("binary"))) {
- buffer_reset(s->frame_type);
+ buffer_clear(s->frame_type);
}
if (!array_is_vlist(s->origins)) {
@@ -347,7 +347,7 @@ static handler_t wstunnel_recv_parse(server *srv, connection *con, http_response
DEBUG_LOG(MOD_WEBSOCKET_LOG_ERR, "s", "fail to send data to client");
return HANDLER_ERROR;
}
- buffer_string_set_length(b, 0);
+ buffer_clear(b);
UNUSED(srv);
UNUSED(con);
return HANDLER_GO_ON;
@@ -844,7 +844,7 @@ static int create_response_rfc_6455(handler_ctx *hctx) {
#endif
value = hctx->srv->tmp_buf;
- buffer_string_set_length(value, 0);
+ buffer_clear(value);
buffer_append_base64_encode(value, sha_digest, SHA_DIGEST_LENGTH, BASE64_STANDARD);
http_header_response_set(con, HTTP_HEADER_OTHER,
CONST_STR_LEN("Sec-WebSocket-Accept"),
@@ -1025,7 +1025,7 @@ static int recv_ietf_00(handler_ctx *hctx) {
&& !buffer_is_empty(payload)) {
hctx->frame.ctl.siz = 0;
chunkqueue_append_buffer(hctx->gw.wb, payload);
- buffer_string_set_length(payload, 0);
+ buffer_clear(payload);
}
else {
if (hctx->frame.state == MOD_WEBSOCKET_FRAME_STATE_INIT
@@ -1043,7 +1043,7 @@ static int recv_ietf_00(handler_ctx *hctx) {
"fail to base64-decode");
return -1;
}
- buffer_string_set_length(payload, 0);
+ buffer_clear(payload);
/*chunkqueue_use_memory()*/
hctx->gw.wb->bytes_in += buffer_string_length(b)-len;
}
@@ -1304,7 +1304,7 @@ static int recv_rfc_6455(handler_ctx *hctx) {
{
unmask_payload(hctx);
chunkqueue_append_buffer(hctx->gw.wb, payload);
- buffer_string_set_length(payload, 0);
+ buffer_clear(payload);
break;
}
case MOD_WEBSOCKET_FRAME_TYPE_PING:
@@ -1313,11 +1313,11 @@ static int recv_rfc_6455(handler_ctx *hctx) {
mod_wstunnel_frame_send(hctx,
MOD_WEBSOCKET_FRAME_TYPE_PONG,
payload->ptr, buffer_string_length(payload));
- buffer_string_set_length(payload, 0);
+ buffer_clear(payload);
}
break;
case MOD_WEBSOCKET_FRAME_TYPE_PONG:
- buffer_string_set_length(payload, 0);
+ buffer_clear(payload);
break;
case MOD_WEBSOCKET_FRAME_TYPE_CLOSE:
default:
diff --git a/src/network.c b/src/network.c
index cbdce555..09d66aaf 100644
--- a/src/network.c
+++ b/src/network.c
@@ -68,7 +68,7 @@ static handler_t network_server_handle_fdevent(server *srv, void *context, int r
}
static void network_host_normalize_addr_str(buffer *host, sock_addr *addr) {
- buffer_reset(host);
+ buffer_clear(host);
sock_addr_stringify_append_buffer(host, addr);
}
diff --git a/src/plugin.c b/src/plugin.c
index b2f81dc8..a509e4e6 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -236,7 +236,6 @@ int plugins_load(server *srv) {
}
#endif
- buffer_reset(srv->tmp_buf);
buffer_copy_string(srv->tmp_buf, module);
buffer_append_string_len(srv->tmp_buf, CONST_STR_LEN("_plugin_init"));
diff --git a/src/response.c b/src/response.c
index 71b255d8..7001a381 100644
--- a/src/response.c
+++ b/src/response.c
@@ -86,10 +86,8 @@ int http_response_write_header(server *srv, connection *con) {
/* cache the generated timestamp */
if (srv->cur_ts != srv->last_generated_date_ts) {
- buffer_string_set_length(srv->ts_date_str, 0);
-
+ buffer_clear(srv->ts_date_str);
buffer_append_strftime(srv->ts_date_str, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&(srv->cur_ts)));
-
srv->last_generated_date_ts = srv->cur_ts;
}
diff --git a/src/server.c b/src/server.c
index 85b2f4a8..5a16dd9e 100644
--- a/src/server.c
+++ b/src/server.c
@@ -964,7 +964,7 @@ static void server_graceful_state (server *srv) {
else {
server_sockets_close(srv);
remove_pid_file(srv);
- buffer_reset(srv->srvconf.pid_file); /*(prevent more removal attempts)*/
+ buffer_clear(srv->srvconf.pid_file); /*(prevent more removal attempts)*/
}
}
@@ -1067,7 +1067,7 @@ static int server_main (server * const srv, int argc, char **argv) {
}
if (test_config) {
- buffer_reset(srv->srvconf.pid_file);
+ buffer_clear(srv->srvconf.pid_file);
if (1 == test_config) {
printf("Syntax OK\n");
} else { /*(test_config > 1)*/
@@ -1090,7 +1090,7 @@ static int server_main (server * const srv, int argc, char **argv) {
graceful_shutdown = 1;
srv->sockets_disabled = 1;
srv->srvconf.dont_daemonize = 1;
- buffer_reset(srv->srvconf.pid_file);
+ buffer_clear(srv->srvconf.pid_file);
if (srv->srvconf.max_worker) {
srv->srvconf.max_worker = 0;
log_error_write(srv, __FILE__, __LINE__, "s",
@@ -1631,7 +1631,7 @@ static int server_main (server * const srv, int argc, char **argv) {
close(pid_fd);
pid_fd = -1;
}
- buffer_reset(srv->srvconf.pid_file);
+ buffer_clear(srv->srvconf.pid_file);
fdevent_clr_logger_pipe_pids();
srv->pid = getpid();
diff --git a/src/stat_cache.c b/src/stat_cache.c
index 1fce38e9..40262fdc 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -546,7 +546,7 @@ const buffer * stat_cache_content_type_get(server *srv, connection *con, const b
if (S_ISREG(sce->st.st_mode)) {
/* determine mimetype */
- buffer_reset(sce->content_type);
+ buffer_clear(sce->content_type);
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
if (con->conf.use_xattr) {
stat_cache_attr_get(sce->content_type, name->ptr, srv->srvconf.xattr_name->ptr);
@@ -709,9 +709,9 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
} else {
- buffer_reset(sce->etag);
+ buffer_clear(sce->etag);
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
- buffer_reset(sce->content_type);
+ buffer_clear(sce->content_type);
#endif
}