[jcifs] threading

Michael B. Allen miallen at eskimo.com
Thu Feb 20 08:26:27 EST 2003

On Wed, 19 Feb 2003 12:11:18 -0500
Dan Dumont <dan at canofsleep.com> wrote:

> Well I have a working threading program.  When I tell the threads to do
> something obnoxious like count to 4 billion, they exit like normal. Bur
> when I tell them each to open a SmbFile and list contents, they block
> until the scanning is complete or there is a connection time out.  Then
> the next thread tries.

Try the T2Crawler or ThreadedSmbCrawler examples (in the examples
directory). If they don't work then you have a more fundamental
problem. If they do work, compare the code.

The jCIFS client will create a thread for every socket it opens. So when
you call some method it uses that thread to write the request but then
calls wait(). The socket thread will notify() the caller thread when
a message is received (or a timeout occurs). I'm not suggesting this
is related to your problem (you haven't provided 1/10th the necessary
information to properly diagnose your problem) but it might help you to
understand how things work internally.

Finally, if you are trying to "scan" or "crawl" over many hosts it
is highly likely that you will get a wide variety of exceptions and
timeouts. In particular if you try to connect to a machine that was
recently turned off (but it's name was still registered with WINS)
it will hang for ~1min15sec. There is *nothing* that you can do about
this. You cannot kill the thread. If you run the ThreadedSmbCrawler for
example on a big WAN with dozens of workgroups and thousands of hosts
there will be periods where all of the threads are waiting for this "No
route to host" timeout. Also, if you are scanning/crawling you will want
to remove BCAST from the resolveOrder property or every lookup failure
will take an extra 6 seconds.


A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 

More information about the jcifs mailing list