libsmbclient query for NetBIOS name every opendir() call with the same argument. If I am not mistake libsmbclient store servers information in cache, but libsmbclient do not use this informatiom (at least ip-address) for subsequent opendir() calls This happen for example with the attached example. See the result.txt for program ouptut. Pay attention to position of "-- %d -------------" lines. It's clear from the output, that libsmbclient make a broadcast query to resolve LASKA hostname every time i use opendir("smb://laska")
Created attachment 1620 [details] test3.c program to reproduce the problem Pay attention to position of "-- %d -------------" lines. It's clear from the output, that libsmbclient make a broadcast query to resolve LASKA hostname every time i use opendir("smb://laska")
Created attachment 1621 [details] test3.c application output Pay attention to position of "-- %d -------------" lines. It's clear from the output, that libsmbclient make a broadcast query to resolve LASKA hostname every time i use opendir("smb://laska")
Try the SVN version now. My recent changes causes a search for an existing server structure with the specified name, and to use it if it exists. If it does not exist, then the previous sequence of events is accomplished to ascertain whether the name is a server or a workgroup, and to go from there.
This solution of the problem is not good enougth. Lets say you are using libnss_wins.so library via /etc/nsswitch.conf to resolve NetBIOS name through the gethostbyname(). In this case you can resolve the NetBIOS group. You'll get a list of computer in a group. Now lets see what happen if I opendir("smb://smbgroup"). using gethostbyname() i receive a list of ip-addresses, but smbc_server() will use only the first one. So libsmbclient tried to connect with one of groups computer instead of master browser. As a result I'll get a list of shares instead of computer list. I think, the check for record in cache (without create if record not found) will solve the problem
Fixed in latest svn version