Kiran VM
2005-Mar-24 14:29 UTC
[Samba] Different behaviour of samba share in XP and Windows 2003 Server
Hello, I have an MFC program that access a file in the samba (3.0.10) share with the following code. CString strSearchPath = _T("\\\\TestServer\\TestShare\\tempfile.txt"); CStdioFile fValueFile; if( !fValueFile.Open(strSearchPath,CFile::modeReadWrite ) ) { cout<<GetLastError()<<endl; } else { cout<<"Opened"<<endl; } //CloseHandle( (HANDLE)fValueFile.m_hFile ); fValueFile.Close(); If i run this code on a Windows 2003 server, it leaves one HANDLE open. but if i try this operation from a windows XP ( with SP2) machine, every thing is fine. Also this leak seems to happen only for a samba share. If the "strSearchPath" is replaced with a Windows share, there is no leak. Number of files opened by our application is quite large and so may handles ( in 1000s ) are held up by the application. With the help of procexp utility i found that the handle used was a file handle (\\TestServer\\TestShare\ wrt to the sample code above. file name was not shown). Did any one face a similar problem? Any idea whether this problem is Samba related (since this happens only for samba shares) ? Any help/pionter in this regard will be of great help. With best regards, Kiran PS: My smb.conf is given below [global] workgroup = NMUSOL netbios name = TestServer interfaces = 132.186.71.238 bind interfaces only = Yes security = DOMAIN password server = 132.186.70.122 log level = 2 ldap ssl = no kernel oplocks = no [TestShare] path = /export/home1/TestShare read only = No oplocks = no strict locking = yes level2 oplocks = no
Gerald (Jerry) Carter
2005-Mar-24 14:38 UTC
[Samba] Different behaviour of samba share in XP and Windows 2003 Server
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kiran VM wrote: | Hello, | | I have an MFC program that access a file in the samba (3.0.10) share | with the following code. | | CString strSearchPath = _T("\\\\TestServer\\TestShare\\tempfile.txt"); | CStdioFile fValueFile; | if( !fValueFile.Open(strSearchPath,CFile::modeReadWrite ) ) | { | cout<<GetLastError()<<endl; | } | else | { | cout<<"Opened"<<endl; | } | | //CloseHandle( (HANDLE)fValueFile.m_hFile ); | fValueFile.Close(); | | If i run this code on a Windows 2003 server, it leaves one HANDLE | open. but if i try this operation from a windows XP ( with SP2) | machine, every thing is fine. | | Also this leak seems to happen only for a samba share. If the | "strSearchPath" is replaced with a Windows share, there is no leak. Could you retest against 3.0.13 and let me know if this is still an issue ? cheers, jerry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCQtDRIR7qMdg1EfYRAj0TAJ9DRpQaOWzGKYVnXTA/JJP6eK4EKgCffL9a f1CSSKUa/MOtT2f3LQ0KFws=9PBL -----END PGP SIGNATURE-----
Kiran VM
2005-Mar-24 15:42 UTC
[Samba] Different behaviour of samba share in XP and Windows 2003 Server
On Thu, 24 Mar 2005 08:38:09 -0600, Gerald (Jerry) Carter <jerry@samba.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Kiran VM wrote: > | Hello, > | > | I have an MFC program that access a file in the samba (3.0.10) share > | with the following code. > | > | CString strSearchPath = _T("\\\\TestServer\\TestShare\\tempfile.txt"); > | CStdioFile fValueFile; > | if( !fValueFile.Open(strSearchPath,CFile::modeReadWrite ) ) > | { > | cout<<GetLastError()<<endl; > | } > | else > | { > | cout<<"Opened"<<endl; > | } > | > | //CloseHandle( (HANDLE)fValueFile.m_hFile ); > | fValueFile.Close(); > | > | If i run this code on a Windows 2003 server, it leaves one HANDLE > | open. but if i try this operation from a windows XP ( with SP2) > | machine, every thing is fine. > | > | Also this leak seems to happen only for a samba share. If the > | "strSearchPath" is replaced with a Windows share, there is no leak. > > Could you retest against 3.0.13 and let me know if this is still > an issue ? > > cheers, jerryHello Jerry, I just now compiled and installed 3.0.13. But the result is the same. Any idea why this is happening? Thanks in advance for your help, Kiran
Kiran VM
2005-Mar-26 05:36 UTC
[Samba] Re: Different behaviour of samba share in XP and Windows 2003 Server
On Thu, 24 Mar 2005 11:01:02 -0800, Jeremy Allison <jra@samba.org> wrote:> On Thu, Mar 24, 2005 at 11:11:44PM +0530, Kiran VM wrote: > > Hello Jerry, > > > > No CloseHandle() call is made in both the case. CFile (or for that > > reason CStdioFile) Close() method will close the OS file handle. > > (closehandle() in the sample code is commented given can be ignored) > > > > Just to make it a bit more clearer, the executable (for testing i just > > put the sample code above inside a for loop of 1000) is run from a > > win2k3 server and xp machine. XP shows no handle increase leak (handle > > count of 85), but in Win2k3 the handle count was around 1085 ( for > > 1000 iterations). This information i got from the windows task > > manager. Upon this, i tried the procexp tool from sysinternals. This > > clearly showed that the Handle being leaked is a file handle, > > \\TestServer\TestShare in our case. (This is not the file as such but > > the directory). > > > > BTW, my samba server is on Solaris 9. > > > > Please let me know if you erquire any further information... > > Can you send me the binary (.exe) of this program. Also, the > information on how to report any handle leaks on the Windows > side. Given that info I can try to track this one on my own. > > Thanks, > > Jeremy. >Hello Jeremy, Hello Jerry, I have attached a test exe (tester.exe) which will reproduce the problem. ( rename the tester.exe1 to tester.exe inside the zip file tester.zip1) Just run tester with the remote file name (from the samba share) as the parameter. (eg. Tester.exe \\TestServer\TestShare\tempfile.txt). The program will open the given file 1000 times in a loop. The source code for this is also attached if you want to make any change. If you run this on a Win2K3 server, the handle count increases to >1000 and on an XP client it is around 10. You can see the handle count in the taskmanager itself. In the process tab of task manager, select the option view->select columns. here check the Handle count check box. Now just monitor the tester.exe process (when it is runnning) in the task manager, you can see the count there. Task manager does not show what kind of handles are open. For this we use a free ware from systinternals (called procexp). This can be downloaded from http://www.sysinternals.com/ntw2k/freeware/procexp.shtml.(i can send it if you want.) Just run this tool and select tester.exe when it is running. This will show all the open handles on the bottom pane. On Win2K3 server, we can see that there are many file handles are open to the directory in our samba share. If you still could not reproduce this problem, please let me know. Also, if you require more info from me, please let me know. Thanks and best regards, Kiran PS: Just a brief desc about by samba config. Im running a 64 bit Samba 3.0.10( tried 3.0.13 also) on Solaris 9 with the smb conf something like this. [global] workgroup = NMUSOL netbios name = TestServer interfaces = 132.186.71.238 bind interfaces only = Yes security = DOMAIN password server = 132.186.70.122 log level = 2 ldap ssl = no kernel oplocks = no [TestShare] path = /export/home1/TestShare read only = No oplocks = no strict locking = yes level2 oplocks = no
Kiran VM
2005-Mar-26 05:52 UTC
[Samba] Re: Different behaviour of samba share in XP and Windows 2003 Server
> > > Hello Jeremy, Hello Jerry, > > I have attached a test exe (tester.exe) which will reproduce the > problem. ( rename the tester.exe1 to tester.exe inside the zip file tester.zip1) > > Just run tester with the remote file name (from the samba share) as > the parameter. (eg. Tester.exe \\TestServer\TestShare\tempfile.txt). > The program will open the given file 1000 times in a loop. The source > code for this is also attached if you want to make any change. If you > run this on a Win2K3 server, the handle count increases to >1000 and > on an XP client it is around 10. > > You can see the handle count in the taskmanager itself. In the process > tab of task manager, select the option view->select columns. here > check the Handle count check box. Now just monitor the tester.exe > process (when it is runnning) in the task manager, you can see the > count there. > > Task manager does not show what kind of handles are open. For this we > use a free ware from systinternals (called procexp). This can be > downloaded from > http://www.sysinternals.com/ntw2k/freeware/procexp.shtml.(i can send > it if you want.) Just run this tool and select > tester.exe when it is running. This will show all the open handles on > the bottom pane. On Win2K3 server, we can see that there are many file > handles are open to the directory in our samba share. > > If you still could not reproduce this problem, please let me know. > Also, if you require more info from me, please let me know. > > Thanks and best regards, > Kiran > > PS: Just a brief desc about by samba config. > > Im running a 64 bit Samba 3.0.10( tried 3.0.13 also) on Solaris 9 > with the smb conf something like this. > > [global] > workgroup = NMUSOL > netbios name = TestServer > interfaces = 132.186.71.238 > bind interfaces only = Yes > security = DOMAIN > password server = 132.186.70.122 > log level = 2 > ldap ssl = no > kernel oplocks = no > > [TestShare] > path = /export/home1/TestShare > read only = No > oplocks = no > strict locking = yes > level2 oplocks = no > > >Hello Jerry, Jeremy, Sorry, iam not able to send attachement to the list so let me put the code in the mail itself. Im Msdev, start a new project, select win32 console application. give the project name as "Tester". Then in the tester.cpp put the following code.... compile and execute as mentioned in my earlier mail. Please let me know if you require any other info. Thanks, Kiran ___________________________________________________________n_ // Tester.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Tester.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr << _T("Fatal Error: MFC initialization failed") << endl; return 1; } if( argc != 2) { cout <<_T("Usage: Tester.exe <complete UNC path of the shared file>")<<endl; cout <<_T("Example: Tester.exe \\\\TestServer\\TestShare\\tempfile.txt")<<endl; return 1; } CString strFileName = argv[1]; int nCount = 1000; cout << _T("Opening file ")<<(LPCTSTR)strFileName<<_T(" ")<<nCount<<_T(" times")<<endl; for (int i = 0; i < nCount ; i++) { CFile fValueFile; if( !fValueFile.Open(strFileName,CFile::modeReadWrite ) ) { cout<<_T("Open failed with error")<<GetLastError()<<endl; } else { cout<<"Opened for iteration "<<i<<endl; } fValueFile.Close(); } cout<<_T("Iteration completed. Press enter to exit")<<endl; getchar(); return 0; } -------------- next part -------------- // Tester.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Tester.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr << _T("Fatal Error: MFC initialization failed") << endl; return 1; } if( argc != 2) { cout <<_T("Usage: Tester.exe <complete UNC path of the shared file>")<<endl; cout <<_T("Example: Tester.exe \\\\TestServer\\TestShare\\tempfile.txt")<<endl; return 1; } CString strFileName = argv[1]; int nCount = 1000; cout << _T("Opening file ")<<(LPCTSTR)strFileName<<_T(" ")<<nCount<<_T(" times")<<endl; for (int i = 0; i < nCount ; i++) { CFile fValueFile; if( !fValueFile.Open(strFileName,CFile::modeReadWrite ) ) { cout<<_T("Open failed with error")<<GetLastError()<<endl; } else { cout<<"Opened for iteration "<<i<<endl; } fValueFile.Close(); } cout<<_T("Iteration completed. Press enter to exit")<<endl; getchar(); return 0; }