Hello there
I am facing a weird problem and wonder if somebody can bring some light on this. The thing is as follow:
I have a Windows 7 system in which Microsoft IFS LSP is installed (http://msdn.microsoft.com/en-us/library/windows/desktop/bb513664(v=vs.85).aspx), then I have my application which basically creates and opens an instance of JmDNS (http://jmdns.sourceforge.net/) to search for services on the network and later I execute a new process through Runtime.getRuntime.exec() command.
Everything works fine, but then, when I tried to close the JmDNS instance the application freeze and the only way to continue is to terminate the process that was launched previously with exec() command (this through the Windows Task Manager).
To explain my case better I coded the following class:
package testing;
import java.io.IOException;
import java.net.InetAddress;
import javax.jmdns.JmDNS;
public class FreezingClass {
public static void main(String... args) {
JmDNS jmdns = null;
// Start JmDNS instance
System.out.println("Initializing JmDNS instance...");
try {
jmdns = JmDNS.create(InetAddress.getLocalHost());
System.out.println("JmDNS instance initialized!");
} catch(IOException ioe) {
System.err.println("Error trying to initialize JmDNS instance\n" + ioe);
}
System.out.println();
// Execute any command with Runtime.getRuntime.exec()
System.out.println("Executing Windows calculator with Runtime.getRuntime.exec() command");
try {
Runtime.getRuntime().exec("C:\\Windows\\System32\\calc.exe");
System.out.println("Calculador launched!");
} catch (IOException ioe) {
System.err.println("Error executing Runtime.getRuntime.exec() command\n" + ioe);
}
System.out.println();
// Close JmDNS instance
System.out.println("Closing JmDNS instace...");
try {
jmdns.close(); // Freeze here while process launched with Runtime.getRuntime.exec() still executing. To continue, close the calculator
System.out.println("JmDNS instance closed!");
} catch (IOException ioe) {
System.err.println("Error trying to close JmDNS instance\n" + ioe);
}
}
}
To reproduce this behavior is needed to:
- Install the Windows 7.1 SDK from Microsoft http://www.microsoft.com/download/en/details.aspx?id=8279, once installed build the sample for the LSP from here:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\netds\winsock\lsp
- Download jmdns.jar file to be used by the application. http://jmdns.sourceforge.net/
Research done on this, points me that a thread is not releasing/closing a socket correctly since it remains reading data that will never arrive. However, I have not gone further than that.
I will really appreciate if anyone has an idea of what could be happening here, or point in the correct direction to solve this problem.
Thanks in advance
Edited by: 901137 on Dec 7, 2011 1:52 PM