[jcifs] Deadlock while cleaning up old sessions in transport

Felix Schumacher felix.schumacher at internetallee.de
Mon Aug 13 09:15:56 GMT 2007

Hi all,

We hit the deadlock (which haunts the archives since a long time) while
cleaning up old sessions in transport, too.
When we traced the usage of setupDiscoLock, it became clear, that it was
called in different order in some paths to treeConnect.
When called from logoff() it would first lock transport and after that it
would try to get setupDiscoLock.
When someone came into treeConnect without any lock that someone would try
to get setupDiscoLock first. (So you get your dining philosopher problem)

To stop this problem you would have to always lock setupDiscoLock first,
but in that case you could use the transport lock instead and get rid of
setupDiscoLock and make the philosophers use only on fork.

This is what the attached patch tries to accomplish.

With it applied we could not reproduce the deadlock anymore.


PS. Why is the cleanup not done in its own thread? The way it is now
implemented will punish somone who just tried to login and gets a new

More information about the jcifs mailing list