From 478cb34bb3abb0a353cc6228f075ae5890cd28a5 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Tue, 22 Nov 2005 14:29:55 +0000 Subject: [PATCH] reverted last patch as open + fstat() results in a hang on named-pipes git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@875 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/stat_cache.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/stat_cache.c b/src/stat_cache.c index f12202e2..148f4c83 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -446,18 +446,27 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_ } } #endif - /* try to open the file */ - if (-1 == (fd = open(name->ptr, O_RDONLY))) { + + /* + * *lol* + * - open() + fstat() on a named-pipe results in a (intended) hang. + * - stat() if regualar file + open() to see if we can read from it is better + * + * */ + + if (-1 == stat(name->ptr, &st)) { return HANDLER_ERROR; } - if (-1 == fstat(fd, &st)) { + + if (S_ISREG(st.st_mode)) { + /* try to open the file to check if we can read it */ + if (-1 == (fd = open(name->ptr, O_RDONLY))) { + return HANDLER_ERROR; + } close(fd); - return HANDLER_ERROR; } - close(fd); - if (NULL == sce) { int osize = 0;