The Samba-Bugzilla – Bug 3257
Broken pipe after lots of connections.
Last modified: 2005-12-05 20:43:47 UTC
I have a program that basically does this:
for (IP = "172.31.[57-60,65].[1-245]")
cout << "Scanning <ip>";
if (smbc_open("smb://<ip>/") succeeds)
cout << "Share: <share>";
// Read a list of shares, and scan the shares for all the files.
// All the files are correctly closed.
cout << "Reinitialising libsmbclient";
context = smbc_set_context(NULL);
if (smbc_init(my_auth_data_fn, debug_level) != 0)
cout << "error";
But obviously more correctly.
With the extra reinitialisation the scan works the first time, then has lots of broken pipes before
scanning the second time (ie between the first and second scans). On the second scan it can't
connect to *any* hosts. The second time it reinitialises the program segfaults (possibly because
context is NULL).
I'll attach a sample output.
Created attachment 1573 [details]
Output of smb scanner.
This is the output from my scanning program.
Solved it using this to reinitialise libsmbclient. It still says all the errors but then it works the next time anyway.
SMBCCTX* context = smbc_set_context(NULL); // Retrieve current context
cout << "Error! Context was null." << endl;
smbc_free_context(context, true); // Close all cached connections
SMBCCTX *statcont1 = smbc_new_context();
cout << "Error creating new context." << endl;
statcont1->debug = 1;
statcont1->callbacks.auth_fn = guest_auth_smbc_get_data;
cout << "Error initialising new context." << endl;
Problem appears to have been a file descriptor leak. Thanks for the report.
Please test from SVN and reopen bug if problem persists.