summaryrefslogtreecommitdiff
path: root/source3/smbd/filename.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-08-28 21:46:29 +0000
committerJeremy Allison <jra@samba.org>1998-08-28 21:46:29 +0000
commit38142a1ebbe860778e26eaff68585726061c05e2 (patch)
tree0112dc0186d8088bab727ee8309c36986c9e72d4 /source3/smbd/filename.c
parentc077bce5c0f760dc918b0442346502ec96a92c1b (diff)
downloadsamba-38142a1ebbe860778e26eaff68585726061c05e2.tar.gz
samba-38142a1ebbe860778e26eaff68585726061c05e2.tar.bz2
samba-38142a1ebbe860778e26eaff68585726061c05e2.zip
This checking fixes the statcache bug that stopped NetBench from running
correctly. Added new parameter "stat cache size" - set to 50 by default. I now declare the statcache code officially "open" for business :-). It gets a hit rate of 97% with a NetBench run and seems to make using a case insensitive run as efficient as a case sensitive run. Also tidied up our sys_select usage - added a maxfd parameter and also added an implementation of select in terms of poll(), for systems where poll() is much faster. This is disabled by default. Jeremy. (This used to be commit 779b924ec1f6c81ff578d22295b20fece698d1fc)
Diffstat (limited to 'source3/smbd/filename.c')
-rw-r--r--source3/smbd/filename.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index de4fef5189..9112828092 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -115,7 +115,8 @@ typedef struct {
static ubi_dlList stat_cache = { NULL, (ubi_dlNodePtr)&stat_cache, 0};
/****************************************************************************
- Compare two names in the stat cache.
+ Compare two names in the stat cache - to check if we already have such an
+ entry.
*****************************************************************************/
static BOOL stat_name_equal( char *s1, char *s2)
@@ -124,13 +125,20 @@ static BOOL stat_name_equal( char *s1, char *s2)
}
/****************************************************************************
- Compare two names in the stat cache.
+ Compare a pathname to a name in the stat cache - of a given length.
+ Note - this code always checks that the next character in the pathname
+ is either a '/' character, or a '\0' character - to ensure we only
+ match *full* pathname components.
*****************************************************************************/
-static BOOL stat_name_equal_len( char *s1, char *s2, int len)
+static BOOL stat_name_equal_len( char *stat_name, char *orig_name, int len)
{
- return (case_sensitive ? (strncmp( s1, s2, len) == 0) :
- (StrnCaseCmp(s1, s2, len) == 0));
+ BOOL matched = (case_sensitive ? (strncmp( stat_name, orig_name, len) == 0) :
+ (StrnCaseCmp(stat_name, orig_name, len) == 0));
+ if(orig_name[len] != '/' && orig_name[len] != '\0')
+ return False;
+
+ return matched;
}
/****************************************************************************
@@ -211,7 +219,7 @@ static void stat_cache_add( char *full_orig_name, char *orig_translated_path)
DEBUG(10,("stat_cache_add: Added entry %s -> %s\n", scp->orig_name, scp->translated_name ));
- if(ubi_dlCount(&stat_cache) > MAX_STAT_CACHE_SIZE) {
+ if(ubi_dlCount(&stat_cache) > lp_stat_cache_size()) {
scp = (stat_cache_entry *)ubi_dlRemTail( &stat_cache );
free((char *)scp);
return;