[jcifs] questions about SmbTransport.getSmbSession

Michael B Allen mba2000 at ioplex.com
Wed Jun 15 17:17:22 GMT 2005


On Wed, 15 Jun 2005 09:03:46 -0500
"Tapperson Kevin" <Kevin.Tapperson at hcahealthcare.com> wrote:

> 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).

No reason. It could be a map. I can only guess that my original reasoning
was that there would usually only be 1 element in the list and therefore
a map would be overkill.

> 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.

Whoops! I think you're right. SO_TIMEOUT was used simply because it
was proportionally the value we are interested in and I don't want 5000
different properties that mean almost the same thing.

I suppose that clause could be tweeked to if (SO_TIMEOUT != 0 && ...

Mike


More information about the jcifs mailing list