Browse Source

- only generate the etag_flags once and store them in the connections

object.


git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1881 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.16
Marcus Rückert 15 years ago
parent
commit
5a583661e3
  1. 3
      src/base.h
  2. 4
      src/configfile.c
  3. 6
      src/mod_staticfile.c
  4. 6
      src/stat_cache.c

3
src/base.h

@ -25,6 +25,7 @@
#include "fdevent.h"
#include "sys-socket.h"
#include "splaytree.h"
#include "etag.h"
#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H
@ -413,6 +414,8 @@ typedef struct {
SSL *ssl;
buffer *ssl_error_want_reuse_buffer;
#endif
/* etag handling */
etag_flags_t etag_flags;
} connection;
typedef struct {

4
src/configfile.c

@ -381,6 +381,10 @@ int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
}
}
con->etag_flags = (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) |
(con->conf.etag_use_inode ? ETAG_USE_INODE : 0) |
(con->conf.etag_use_size ? ETAG_USE_SIZE : 0);
return 0;
}
#undef PATCH

6
src/mod_staticfile.c

@ -453,11 +453,7 @@ URIHANDLER_FUNC(mod_staticfile_subrequest) {
response_header_overwrite(srv, con, CONST_STR_LEN("Accept-Ranges"), CONST_STR_LEN("bytes"));
if (allow_caching) {
etag_flags_t flags;
flags = (con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0);
if (p->conf.etags_used && flags != 0 && !buffer_is_empty(sce->etag)) {
if (p->conf.etags_used && con->etag_flags != 0 && !buffer_is_empty(sce->etag)) {
if (NULL == array_get_element(con->response.headers, "ETag")) {
/* generate e-tag */
etag_mutate(con->physical.etag, sce->etag);

6
src/stat_cache.c

@ -608,16 +608,14 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
break;
}
}
etag_create(sce->etag, &(sce->st),
(con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0));
etag_create(sce->etag, &(sce->st), con->etag_flags);
#ifdef HAVE_XATTR
if (con->conf.use_xattr && buffer_is_empty(sce->content_type)) {
stat_cache_attr_get(sce->content_type, name->ptr);
}
#endif
} else if (S_ISDIR(st.st_mode)) {
etag_create(sce->etag, &(sce->st),
(con->conf.etag_use_mtime ? ETAG_USE_MTIME : 0) | (con->conf.etag_use_inode ? ETAG_USE_INODE : 0) | (con->conf.etag_use_size ? ETAG_USE_SIZE : 0));
etag_create(sce->etag, &(sce->st), con->etag_flags);
}
#ifdef HAVE_FAM_H

Loading…
Cancel
Save