Libsmbclient - listing workgroups timeout
Henrik Zagerholm
henke at mac.se
Tue Nov 7 16:32:44 GMT 2006
Hello list,
We are having trouble with listing workgroups and setting a timeout
at the same time.
It feels that the open call on "smb://" does not honor the timeout
setting.
The only thing that affect the time spent searching for workgrousp/
domains seems to be to set the options.browse_max_lmb_count.
Is there someway to have a high lmb_count but still be able to set a
shorter timeout?
Below is a code snipppet from what we are trying to do.
Any input would be appreciated!
Cheers,
henrik
// Initiating context
SMBCCTX *m_pSambaContext = NULL;
m_pSambaContext = smbc_new_context();
if( !(m_pSambaContext) )
throw "Could not allocate new smbc context";
m_pSambaContext->debug = 0;
m_pSambaContext->callbacks.auth_fn = authenticate;
/* Initialize the context using the previously specified
options */
if( !smbc_init_context(m_pSambaContext) )
{
smbc_free_context( m_pSambaContext, 1 );
throw "Could not initialize smbc context";
}
static char *pszEmptyString = "";
if( !m_pSambaContext )
return pszEmptyString;
m_pSambaContext->options.browse_max_lmb_count = 3;
m_pSambaContext->timeout = 100;
std::string strOpen("smb://");
std::string strWorkgroups;
// fd < 0 if error on opendir
SMBCFILE *dir = m_pSambaContext->opendir( m_pSambaContext,
strOpen.c_str() ); // <------------ This takes a lot longer time than
the set timeout
smbc_dirent *pDirEnt = 0;
if( dir >= 0 )
{
while( pDirEnt = m_pSambaContext->readdir(m_pSambaContext,
dir) )
{
if( strWorkgroups.empty() )
{
strWorkgroups = pDirEnt->name;
continue;
}
strWorkgroups += std::string(",") + pDirEnt->name;
}
m_pSambaContext->closedir( m_pSambaContext, dir );
}
if( m_pszBuffer ) delete[] m_pszBuffer;
m_pszBuffer = new char[strWorkgroups.length() + 1];
strcpy(m_pszBuffer, strWorkgroups.c_str());
// comma separated string
return m_pszBuffer;
More information about the samba-technical
mailing list