[jcifs] questions about SmbTransport.getSmbSession
Tapperson Kevin
Kevin.Tapperson at hcahealthcare.com
Wed Jun 15 14:03:46 GMT 2005
I have a few questions about SmbTransport.getSmbSession; maybe someone can answer them.
Here is a copy of the method for reference:
synchronized SmbSession getSmbSession( NtlmPasswordAuthentication auth ) {
SmbSession ssn;
ListIterator iter = sessions.listIterator();
while( iter.hasNext() ) {
ssn = (SmbSession)iter.next();
if( ssn.matches( auth )) {
ssn.auth = auth;
return ssn;
}
}
/* close old sessions */
long now = System.currentTimeMillis();
if( sessionExpiration < now ) {
sessionExpiration = now + SO_TIMEOUT;
iter = sessions.listIterator();
while( iter.hasNext() ) {
ssn = (SmbSession)iter.next();
if( ssn.expiration < now ) {
ssn.logoff( false );
iter.remove();
}
}
}
ssn = new SmbSession( address, port, localAddr, localPort, auth );
ssn.transport = this;
sessions.add( ssn );
return ssn;
}
1) Is there any reason that the sessions object in SmbTransport is a LinkedList? I think it would make more sense to implement the sessions object as a Map (using an NtlmPasswordAuthentication object as the key). This would provide constant time access to a matching SmbSession in the getSmbSession method rather than linear time as it is currently. The first section of code above could be replaced as follows:
ssn = (SmbSession)sessions.get( auth );
if( ssn != null ) {
ssn.auth = auth;
return ssn;
}
2) Why was SO_TIMEOUT chosen as the poll interval for the session expiration/cleanup code in SmbTransport.getSmbSession? We have jcifs.smb.client.soTimeout set to 0 to avoid getting NT_STATUS_ACCESS_VIOLATION errors (see previous threads related to soTimeout). I am concerned that because of this we are suffering a performance penalty in that our SmbSessions expire immediately on creation. On our QA servers, we have seen an issue with our login functionality when there is a high degree of concurrency. We are in the process of conducting further performance testing to isolate the problem.
-------------- next part --------------
HTML attachment scrubbed and removed
More information about the jcifs
mailing list