summaryrefslogtreecommitdiff
path: root/src/stat_cache.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-03-28 00:28:53 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-03-28 02:17:33 -0400
commite1164797318234d1f24bba269f2b16099d26ef36 (patch)
tree5c1a650a1b454d87b77b40592de052c0a3ca0cdb /src/stat_cache.c
parentba953cdf458b05c8e93765722704a7eda1e66e2e (diff)
downloadlighttpd1.4-e1164797318234d1f24bba269f2b16099d26ef36.tar.gz
lighttpd1.4-e1164797318234d1f24bba269f2b16099d26ef36.zip
[core] make stat_cache private to stat_cache.c
Diffstat (limited to 'src/stat_cache.c')
-rw-r--r--src/stat_cache.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/stat_cache.c b/src/stat_cache.c
index 8e4468d1..48a38c5a 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -4,6 +4,7 @@
#include "stat_cache.h"
#include "fdevent.h"
#include "etag.h"
+#include "splaytree.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -93,7 +94,22 @@ typedef struct {
static fake_keys ctrl;
#endif
-stat_cache *stat_cache_init(void) {
+typedef struct stat_cache {
+ splay_tree *files; /* the nodes of the tree are stat_cache_entry's */
+
+ buffer *dir_name; /* for building the dirname from the filename */
+#ifdef HAVE_FAM_H
+ splay_tree *dirs; /* the nodes of the tree are fam_dir_entry */
+
+ FAMConnection fam;
+ int fam_fcce_ndx;
+#endif
+ buffer *hash_key; /* temp-store for the hash-key */
+} stat_cache;
+
+static handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent);
+
+stat_cache *stat_cache_init(server *srv) {
stat_cache *sc = NULL;
sc = calloc(1, sizeof(*sc));
@@ -110,6 +126,24 @@ stat_cache *stat_cache_init(void) {
ctrl.size = 0;
#endif
+#ifdef HAVE_FAM_H
+ /* setup FAM */
+ if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
+ if (0 != FAMOpen2(&srv->stat_cache->fam, "lighttpd")) {
+ log_error_write(srv, __FILE__, __LINE__, "s",
+ "could not open a fam connection, dieing.");
+ return NULL;
+ }
+#ifdef HAVE_FAMNOEXISTS
+ FAMNoExists(&srv->stat_cache->fam);
+#endif
+
+ fd_close_on_exec(FAMCONNECTION_GETFD(&srv->stat_cache->fam));
+ fdevent_register(srv->ev, FAMCONNECTION_GETFD(&srv->stat_cache->fam), stat_cache_handle_fdevent, NULL);
+ fdevent_event_set(srv->ev, &(srv->stat_cache->fam_fcce_ndx), FAMCONNECTION_GETFD(&srv->stat_cache->fam), FDEVENT_IN);
+ }
+#endif
+
return sc;
}
@@ -247,7 +281,7 @@ static uint32_t hashme(buffer *str) {
}
#ifdef HAVE_FAM_H
-handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent) {
+static handler_t stat_cache_handle_fdevent(server *srv, void *_fce, int revent) {
size_t i;
stat_cache *sc = srv->stat_cache;
size_t events;