r2076: Removed old dir caching code - not being used now we have the
authorJeremy Allison <jra@samba.org>
Wed, 25 Aug 2004 23:20:47 +0000 (23:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:30 +0000 (10:52 -0500)
statcache anyway. New dir caching will be done on nanosecond
timestamps.
Jeremy.
(This used to be commit ba473a580245430009245a4c8b8dcaf9fc4b6406)

source3/include/smb_macros.h
source3/smbd/dir.c
source3/smbd/filename.c
source3/smbd/service.c

index bcbaa64f8633b2a7f441df4b95884dfa309c8655..a9e911c066ac2ced4d836a4051815271754c2d17 100644 (file)
@@ -26,7 +26,6 @@
 
 /* Misc bit macros */
 #define BOOLSTR(b) ((b) ? "Yes" : "No")
-#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
 
 /* for readability... */
index b88f687766d88ba9766956024a5159f4950a51c2..2bda42f76dc84c5097e6a4df23e7b5d7fce11d15 100644 (file)
@@ -986,112 +986,3 @@ int TellDir(void *p)
   
        return(dirp->pos);
 }
-
-/*******************************************************************************
- This section manages a global directory cache.
- (It should probably be split into a separate module.  crh)
-********************************************************************************/
-
-typedef struct {
-       ubi_dlNode node;
-       char *path;
-       char *name;
-       char *dname;
-       int snum;
-} dir_cache_entry;
-
-static ubi_dlNewList( dir_cache );
-
-/*****************************************************************************
- Add an entry to the directory cache.
- Input:  path  -
-         name  -
-         dname -
-         snum  -
- Output: None.
-*****************************************************************************/
-
-void DirCacheAdd( const char *path, const char *name, const char *dname, int snum )
-{
-       int pathlen;
-       int namelen;
-       dir_cache_entry  *entry;
-
-       /*
-        * Allocate the structure & string space in one go so that it can be freed
-        * in one call to free().
-        */
-       pathlen = strlen(path) + 1;  /* Bytes required to store path (with nul). */
-       namelen = strlen(name) + 1;  /* Bytes required to store name (with nul). */
-       entry = (dir_cache_entry *)malloc( sizeof( dir_cache_entry )
-                                       + pathlen
-                                       + namelen
-                                       + strlen( dname ) +1 );
-       if( NULL == entry )   /* Not adding to the cache is not fatal,  */
-               return;             /* so just return as if nothing happened. */
-
-       /* Set pointers correctly and load values. */
-       entry->path  = memcpy( (char *)&entry[1], path, strlen(path)+1 );
-       entry->name  = memcpy( &(entry->path[pathlen]), name, strlen(name)+1 );
-       entry->dname = memcpy( &(entry->name[namelen]), dname, strlen(dname)+1 );
-       entry->snum  = snum;
-
-       /* Add the new entry to the linked list. */
-       (void)ubi_dlAddHead( dir_cache, entry );
-       DEBUG( 4, ("Added dir cache entry %s %s -> %s\n", path, name, dname ) );
-
-       /* Free excess cache entries. */
-       while( DIRCACHESIZE < dir_cache->count )
-               safe_free( ubi_dlRemTail( dir_cache ) );
-}
-
-/*****************************************************************************
- Search for an entry to the directory cache.
- Input:  path  -
-         name  -
-         snum  -
- Output: The dname string of the located entry, or NULL if the entry was
-         not found.
-
- Notes:  This uses a linear search, which is is okay because of
-         the small size of the cache.  Use a splay tree or hash
-         for large caches.
-*****************************************************************************/
-
-char *DirCacheCheck( const char *path, const char *name, int snum )
-{
-       dir_cache_entry *entry;
-
-       for( entry = (dir_cache_entry *)ubi_dlFirst( dir_cache );
-                       NULL != entry;
-                       entry = (dir_cache_entry *)ubi_dlNext( entry ) ) {
-               if( entry->snum == snum
-                               && entry->name && 0 == strcmp( name, entry->name )
-                               && entry->path && 0 == strcmp( path, entry->path ) ) {
-                       DEBUG(4, ("Got dir cache hit on %s %s -> %s\n",path,name,entry->dname));
-                       return( entry->dname );
-               }
-       }
-
-       return(NULL);
-}
-
-/*****************************************************************************
- Remove all cache entries which have an snum that matches the input.
- Input:  snum  -
- Output: None.
-*****************************************************************************/
-
-void DirCacheFlush(int snum)
-{
-       dir_cache_entry *entry;
-       ubi_dlNodePtr    next;
-
-       for(entry = (dir_cache_entry *)ubi_dlFirst( dir_cache ); 
-           NULL != entry; )  {
-               next = ubi_dlNext( entry );
-               if( entry->snum == snum )
-                       safe_free( ubi_dlRemThis( dir_cache, entry ) );
-               entry = (dir_cache_entry *)next;
-       }
-}
index cc1c0a40b665f2ae820ab0172eed68a6f84a9d26..e12cfb1388bb17a284189b7b20093a14818829fe 100644 (file)
@@ -26,8 +26,7 @@
 
 #include "includes.h"
 
-static BOOL scan_directory(const char *path, char *name,size_t maxlength,
-                          connection_struct *conn,BOOL docache);
+static BOOL scan_directory(connection_struct *conn, const char *path, char *name,size_t maxlength);
 
 /****************************************************************************
  Check if two filenames are equal.
@@ -282,10 +281,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
                         */
 
                        if (ms_has_wild(start) || 
-                           !scan_directory(dirpath, start, 
-                                           sizeof(pstring) - 1 - (start - name), 
-                                           conn, 
-                                           end?True:False)) {
+                           !scan_directory(conn, dirpath, start, sizeof(pstring) - 1 - (start - name))) {
                                if (end) {
                                        /*
                                         * An intermediate part of the name can't be found.
@@ -450,8 +446,7 @@ BOOL check_name(pstring name,connection_struct *conn)
  If the name looks like a mangled name then try via the mangling functions
 ****************************************************************************/
 
-static BOOL scan_directory(const char *path, char *name, size_t maxlength, 
-                          connection_struct *conn,BOOL docache)
+static BOOL scan_directory(connection_struct *conn, const char *path, char *name, size_t maxlength)
 {
        void *cur_dir;
        const char *dname;
@@ -463,11 +458,6 @@ static BOOL scan_directory(const char *path, char *name, size_t maxlength,
        if (*path == 0)
                path = ".";
 
-       if (docache && (dname = DirCacheCheck(path,name,SNUM(conn)))) {
-               safe_strcpy(name, dname, maxlength);    
-               return(True);
-       }      
-
        /*
         * The incoming name can be mangled, and if we de-mangle it
         * here it will not compare correctly against the filename (name2)
@@ -505,8 +495,6 @@ static BOOL scan_directory(const char *path, char *name, size_t maxlength,
 
                if ((mangled && mangled_equal(name,dname,SNUM(conn))) || fname_equal(name, dname, conn->case_sensitive)) {
                        /* we've found the file, change it's name and return */
-                       if (docache)
-                               DirCacheAdd(path,name,dname,SNUM(conn));
                        safe_strcpy(name, dname, maxlength);
                        CloseDir(cur_dir);
                        return(True);
index 794b5332ac5eaaf7fff503faac68bbb4d60b94eb..5ebd772aa1d222e71b46df5da15409b4bebc1f8e 100644 (file)
@@ -821,8 +821,6 @@ close a cnum
 ****************************************************************************/
 void close_cnum(connection_struct *conn, uint16 vuid)
 {
-       DirCacheFlush(SNUM(conn));
-
        if (IS_IPC(conn)) {
                pipe_close_conn(conn);
        } else {