[jcifs] Thread Leak part deux

Michael B Allen ioplex at gmail.com
Mon Apr 5 19:34:38 MDT 2010


On Thu, Apr 1, 2010 at 2:13 PM, David McReynolds
<david.mcreynolds at gmail.com> wrote:
> What is this supposed to do?
>
>            if (false && NETBIOS_HOSTNAME != null &&
> NETBIOS_HOSTNAME.equals( "" ) == false) {
>                port = 139;
>            }

You seem to have missed the comment above the:

  /* If jcifs.netbios.hostname is set this *probably* means there
   * is a policy regarding which hosts a user can connect from. This
   * requires communicating over port 139 rather than 445.
   */
  if (false && NETBIOS_HOSTNAME != null && NETBIOS_HOSTNAME.equals( ""
) == false) {
      port = 139;
  }

So the logic was that if the jcifs.netbios.hostname property was set,
port 139 should be used so that the old "can only connect from these
computers" hostname security policy could be effected. But because
port 139 and that security policy is no longer used, the 'false &&'
was added to disable this behavior. In practice the three lines and
it's comment should have just been removed entirely to prevent someone
from becoming confused by this useless block of code (the JCIFS
codebase is 10 years old). I just removed it. Thanks for the feedback.

> How about
>
>            if ((NETBIOS_HOSTNAME != null) &&
> (!NETBIOS_HOSTNAME.equals( "" ))) {
>
>
> Also, since this was the last response concerning something that could
> be fixed in 4 lines of code. I am posting this little code snippet
> because if I let my daemon run overnight it ends up with 1800 blocked
> threads.

Again, so far you have not demonstrated that there is anything to be
"fixed". I'm not stating that there isn't a bug behind the behavior
that you're seeing. You just haven't shown me what it is.

I believe your last message claimed that BCAST was required for your
application to function? That NetBIOS behavior is only emitted by
pre-Windows 2000 systems. So if your application depends on it, I
would suggest you find another solution to whatever it is that you're
doing.

Mike

>
> From July 2009
>> Ok, this looks like something worth fixing. I think using the 1.4
>> timeout looks like the right track but I haven't really looked at the
>> problem so I don't know. Aslo, unfortunately this is the sort of thing
>> that could take a really long time to make it into the code since I
>> don't really work on JCIFS for free or Free anymore. But I've added
>> this to the TODO.
>>
>> Thanks for the report.
>>
>> Mike
>
> The fix, 9 months later.
>                InetAddress addr =
> InetAddress.getByName(address.getHostAddress());
>                if(!addr.isReachable(SO_TIMEOUT)) {
>                 throw new IOException("host unreachable");
>                }
>
> and if you want to be thorough.
>
>            if (port == 139) {
>                ssn139();
>            } else {
>                if (port == 0) {
>                    port = DEFAULT_PORT; // 445
>                }
>
>                InetAddress addr =
> InetAddress.getByName(address.getHostAddress()); //fix
>                if(!addr.isReachable(SO_TIMEOUT)) {
>             //fix
>                 throw new IOException("host unreachable");
>          //fix
>                }
>             //fix
>
>                if (localAddr == null) {
>                    InetSocketAddress remoteAddr = new
> InetSocketAddress(addr, port);//fix
>                    socket = new Socket();
>              //fix
>                    socket.connect(remoteAddr, SO_TIMEOUT);
>              //fix
>                } else {
>                    socket = new Socket();
>                     //fix
>                    InetSocketAddress remoteAddr = new
> InetSocketAddress(addr, port);       //fix
>                    InetSocketAddress localAdd = new
> InetSocketAddress(localAddr,localPort);//fix
>                    socket.bind(localAdd);
>                     //fix
>                    socket.connect(remoteAddr,SO_TIMEOUT);
>                     //fix
>                }
>
>                socket.setSoTimeout( SO_TIMEOUT );
>                out = socket.getOutputStream();
>                in = socket.getInputStream();
>            }
>
> --
> dlm
>



-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list