[jcifs] Thread Leak part deux
John Baker
jbaker at javasystemsolutions.com
Thu Apr 1 12:17:50 MDT 2010
Actually, NETBIOS_HOSTNAME.length()=0 is neater :)
-----Original Message-----
From: David McReynolds <david.mcreynolds at gmail.com>
Date: Thu, 1 Apr 2010 14:13:55
To: <jcifs at lists.samba.org>
Subject: [jcifs] Thread Leak part deux
What is this supposed to do?
if (false && NETBIOS_HOSTNAME != null &&
NETBIOS_HOSTNAME.equals( "" ) == false) {
port = 139;
}
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.
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
More information about the jCIFS
mailing list