Browse Source

add support for the original libfam and handle HUP on the fam-fd

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@622 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 17 years ago
parent
commit
79d3bc4491
  1. 29
      configure.in
  2. 85
      src/stat_cache.c

29
configure.in

@ -260,16 +260,29 @@ if test -z "$PKG_CONFIG"; then
fi
dnl Check for gamin
AC_MSG_CHECKING(for gamin)
AC_ARG_WITH(gamin, AC_HELP_STRING([--with-gamin],[gamin for reducing number of stat() calls]),
[WITH_GAMIN=$withval],[WITH_GAMIN=no])
AC_MSG_RESULT([$WITH_GAMIN])
if test "$WITH_GAMIN" != "no"; then
PKG_CHECK_MODULES(FAM, gamin >= 0.1.0, [
AC_MSG_CHECKING(for FAM)
AC_ARG_WITH(fam, AC_HELP_STRING([--with-fam],[fam/gamin for reducing number of stat() calls]),
[WITH_FAM=$withval],[WITH_FAM=no])
AC_MSG_RESULT([$WITH_FAM])
if test "$WITH_FAM" != "no"; then
AC_CHECK_LIB(fam, FAMOpen2, [
AC_CHECK_HEADERS([fam.h],[
FAM_LIBS=-lfam
AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
])
])
])
if test "x$FAM_LIBS" = x; then
PKG_CHECK_MODULES(FAM, gamin >= 0.1.0, [
AC_DEFINE([HAVE_LIBFAM], [1], [libfam])
AC_DEFINE([HAVE_FAM_H], [1], [fam.h])
])
fi
OLD_LIBS=$LIBS
LIBS=$FAM_LIBS
AC_CHECK_FUNCS([FAMNoExists])
LIBS=$OLD_LIBS
fi
AC_MSG_CHECKING(for properties in mod_webdav)

85
src/stat_cache.c

@ -98,8 +98,9 @@ stat_cache *stat_cache_init(void) {
if (0 != FAMOpen2(fc->fam, "lighttpd")) {
return NULL;
}
#ifdef HAVE_FAMNOEXISTS
FAMNoExists(fc->fam);
#endif
#endif
return fc;
@ -173,9 +174,11 @@ void stat_cache_free(stat_cache *fc) {
#ifdef HAVE_FAM_H
splaytree_delete_tree(fc->dirs, fam_dir_entry_free);
FAMClose(fc->fam);
free(fc->fam);
if (fc->fam) {
FAMClose(fc->fam);
free(fc->fam);
}
#endif
free(fc);
}
@ -217,46 +220,63 @@ handler_t stat_cache_handle_fdevent(void *_srv, void *_fce, int revent) {
UNUSED(revent);
/* */
events = FAMPending(sc->fam);
if ((revent & FDEVENT_IN) &&
sc->fam) {
events = FAMPending(sc->fam);
for (i = 0; i < events; i++) {
FAMEvent fe;
fam_dir_entry *fam_dir;
splay_tree *node;
int ndx;
for (i = 0; i < events; i++) {
FAMEvent fe;
fam_dir_entry *fam_dir;
splay_tree *node;
int ndx;
FAMNextEvent(sc->fam, &fe);
FAMNextEvent(sc->fam, &fe);
/* handle event */
/* handle event */
switch(fe.code) {
case FAMChanged:
case FAMDeleted:
case FAMMoved:
/* if the filename is a directory remove the entry */
switch(fe.code) {
case FAMChanged:
case FAMDeleted:
case FAMMoved:
/* if the filename is a directory remove the entry */
fam_dir = fe.userdata;
fam_dir->version++;
fam_dir = fe.userdata;
fam_dir->version++;
/* file/dir is still here */
if (fe.code == FAMChanged) break;
/* file/dir is still here */
if (fe.code == FAMChanged) break;
buffer_copy_string(sc->dir_name, fe.filename);
buffer_copy_string(sc->dir_name, fe.filename);
ndx = hashme(sc->dir_name);
ndx = hashme(sc->dir_name);
sc->dirs = splaytree_splay(sc->dirs, ndx);
node = sc->dirs;
sc->dirs = splaytree_splay(sc->dirs, ndx);
node = sc->dirs;
if (node && (node->key == ndx)) {
fam_dir_entry_free(node->data);
sc->dirs = splaytree_delete(sc->dirs, ndx);
if (node && (node->key == ndx)) {
fam_dir_entry_free(node->data);
sc->dirs = splaytree_delete(sc->dirs, ndx);
}
break;
default:
break;
}
break;
default:
break;
}
}
if (revent & FDEVENT_HUP) {
/* fam closed the connection */
srv->stat_cache->fam_fcce_ndx = -1;
fdevent_event_del(srv->ev, &(sc->fam_fcce_ndx), FAMCONNECTION_GETFD(sc->fam));
fdevent_unregister(srv->ev, FAMCONNECTION_GETFD(sc->fam));
FAMClose(sc->fam);
free(sc->fam);
sc->fam = NULL;
}
return HANDLER_GO_ON;
}
@ -397,7 +417,8 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
}
#ifdef HAVE_FAM_H
if (srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM) {
if (sc->fam &&
(srv->srvconf.stat_cache_engine == STAT_CACHE_ENGINE_FAM)) {
/* is this directory already registered ? */
if (!dir_node) {
fam_dir = fam_dir_entry_init();

Loading…
Cancel
Save