diff options
author | Olivier Sessink <oliviersessink@gmail.com> | 2011-08-09 09:56:38 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-08-23 16:51:20 +0200 |
commit | 89b672f24797f7ecc2ac5191a33a1ae5a38e07cc (patch) | |
tree | 5ff22986e7260b0d5a28066d819b3ec6182df3f5 /source3 | |
parent | 5007ad30265caa01d973c1964118a779c6ee68ef (diff) | |
download | samba-89b672f24797f7ecc2ac5191a33a1ae5a38e07cc.tar.gz samba-89b672f24797f7ecc2ac5191a33a1ae5a38e07cc.tar.bz2 samba-89b672f24797f7ecc2ac5191a33a1ae5a38e07cc.zip |
scannedonly module: improve sleep behavior when reading a directory with multiple non-scanned files
Diffstat (limited to 'source3')
-rw-r--r-- | source3/modules/vfs_scannedonly.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/source3/modules/vfs_scannedonly.c b/source3/modules/vfs_scannedonly.c index 6d748c4c23..c1821bdee8 100644 --- a/source3/modules/vfs_scannedonly.c +++ b/source3/modules/vfs_scannedonly.c @@ -1,7 +1,7 @@ /* - * scannedonly VFS module for Samba 3.5 + * scannedonly VFS module for Samba 3.5 and beyond * - * Copyright 2007,2008,2009,2010 (C) Olivier Sessink + * Copyright 2007,2008,2009,2010,2011 (C) Olivier Sessink * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,7 +88,8 @@ struct Tscannedonly { struct scannedonly_DIR { char *base; - int notify_loop_done; + int recheck_tries_done; /* if 0 the directory listing has not yet + been checked for files that need to be scanned. */ SMB_STRUCT_DIR *DIR; }; #define SCANNEDONLY_DEBUG 9 @@ -441,8 +442,7 @@ static bool scannedonly_allow_access(vfs_handle_struct * handle, notify_scanner(handle, smb_fname->base_name); - didloop = 0; - if (loop && sDIR && !sDIR->notify_loop_done) { + if (loop && sDIR && sDIR->recheck_tries_done == 0) { /* check the rest of the directory and notify the scanner if some file needs scanning */ long offset; @@ -467,27 +467,29 @@ static bool scannedonly_allow_access(vfs_handle_struct * handle, talloc_free(smb_fname2); dire = SMB_VFS_NEXT_READDIR(handle, sDIR->DIR,NULL); } - sDIR->notify_loop_done = 1; - didloop = 1; + sDIR->recheck_tries_done = 1; SMB_VFS_NEXT_SEEKDIR(handle, sDIR->DIR, offset); } if (recheck_time > 0 && ((recheck_size > 0 && smb_fname->st.st_ex_size < (1024 * recheck_size)) - || didloop)) { - int i = 0; + || (sDIR && sDIR->recheck_tries_done < recheck_tries) + )) { + int numloops = sDIR ? sDIR->recheck_tries_done : 0; flush_sendbuffer(handle); while (retval != 0 /*&& errno == ENOENT */ - && i < recheck_tries) { + && numloops < recheck_tries) { DEBUG(SCANNEDONLY_DEBUG, ("scannedonly_allow_access, wait (try=%d " "(max %d), %d ms) for %s\n", - i, recheck_tries, + numloops, recheck_tries, recheck_time, cache_smb_fname->base_name)); smb_msleep(recheck_time); retval = SMB_VFS_NEXT_STAT(handle, cache_smb_fname); - i++; + numloops++; } + if (sDIR) + sDIR->recheck_tries_done = numloops; } /* still no cachefile, or still too old, return 0 */ if (retval != 0 @@ -525,7 +527,7 @@ static SMB_STRUCT_DIR *scannedonly_opendir(vfs_handle_struct * handle, DEBUG(SCANNEDONLY_DEBUG, ("scannedonly_opendir, fname=%s, base=%s\n",fname,sDIR->base)); sDIR->DIR = DIRp; - sDIR->notify_loop_done = 0; + sDIR->recheck_tries_done = 0; return (SMB_STRUCT_DIR *) sDIR; } @@ -553,7 +555,7 @@ static SMB_STRUCT_DIR *scannedonly_fdopendir(vfs_handle_struct * handle, DEBUG(SCANNEDONLY_DEBUG, ("scannedonly_fdopendir, fname=%s, base=%s\n",fname,sDIR->base)); sDIR->DIR = DIRp; - sDIR->notify_loop_done = 0; + sDIR->recheck_tries_done = 0; return (SMB_STRUCT_DIR *) sDIR; } |