From: James Peterson Date: Sat, 10 Feb 2001 20:46:15 +0000 (+0000) Subject: winnt-directory-scan-memory-leak-20010210 X-Git-Tag: BP-openafs-devel-autoconf~89 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=83074e0491fb5a215ffdb223280a3c3428edd29e;p=packages%2Fo%2Fopenafs.git winnt-directory-scan-memory-leak-20010210 "Problem: During a directory scan W2K does not send the FindClose the way NT does. When smb_ReceiveTran2SearchDir() processes FindFirst or FindNext, the termination Flags is never set either (close search if end of search). Since these operations don't occur smb_DeleteDirSearch() is never called; therefore the dsp (smb_dirSearch_t) is never freed. This problem was reproducible while trying to scan a directory (e.g. dir *.c/s) with symbolic links. When smb_ReceiveTran2SearchDir() processes FindFirst or FindNext the last SMB call in a session can be indicated by checking for no more files (filesnames==0). Running a directory scan (DOS window) and file cache size of 5 MB: With the memory leak patch, the program grew upto the limit of +5.3MB. Without the patch, the program will grew +27MB before the operation was finished, then became unstable." --- diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index f6067288d..8f3c5cb5c 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -2367,7 +2367,8 @@ nextEntry: * we're supposed to close the search if we're done, and we're done, * or if something went wrong, close the search. */ - if ((searchFlags & 1) || ((searchFlags & 2) && eos) + /* ((searchFlags & 1) || ((searchFlags & 2) && eos) */ + if ((searchFlags & 1) || (returnedNames == 0) || code != 0) smb_DeleteDirSearch(dsp); if (code) smb_SendTran2Error(vcp, p, opx, code);