[jcifs] Restoring connection after samba server restart

Dmytro Polivenok polivenok at yandex.ua
Wed Jul 27 09:29:09 MDT 2011


Hi,

We are experiencing issues with restoring connection after samba server restart. It is important for us and may be important to other people since we are using jCIFS from application on JBoss server and to recover connection we need to refresh connection somehow. 
We found that it is related to TID regeneration. TIDs are generated after server startup and on server restart all TIDs are regenerated. jCIFS caches TIDs and after server restart or shared folder recreation it is unable to access resource because uses old TIDs and doesn’t refreshes them.



In SmbTree class in method void send(ServerMessageBlock request, ServerMessageBlock response)  at the end of the method there is following code:


    try {

        session.send(request, response);

    } catch(SmbException se) {

        if(se.getNtStatus() == se.NT_STATUS_NETWORK_NAME_DELETED) {

            treeDisconnect(true);

        }

		throw se;

    }



Method treeDisconnect contains code related to removing old TIDs.

When TID is invalid, NtStatus is equal to NT_STATUS_INVALID_PARAMETER.


So I changed this code in the following way to refresh TID when it is invalid:



    try {

        session.send(request, response);

    } catch(SmbException se) {

        if(se.getNtStatus() == se.NT_STATUS_NETWORK_NAME_DELETED || se.getNtStatus() == se.NT_STATUS_INVALID_PARAMETER) {

			treeDisconnect(true);

        }

        throw se;

    }

What do you think about this?

Thanks,
Dmytro


More information about the jCIFS mailing list