Reactivate Server.checkPort() but try to use a server socket instead of connecting with a client socket as suggested by Daniel Ruthardt in bug 637 <http://helma.org/bugs/show_bug.cgi?id=637>
This commit is contained in:
parent
fb12fd3e4d
commit
a8677d1afc
1 changed files with 9 additions and 15 deletions
|
@ -32,6 +32,9 @@ import java.io.*;
|
||||||
import java.rmi.registry.*;
|
import java.rmi.registry.*;
|
||||||
import java.rmi.server.*;
|
import java.rmi.server.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
import helma.util.ResourceProperties;
|
import helma.util.ResourceProperties;
|
||||||
|
|
||||||
|
@ -370,13 +373,11 @@ public class Server implements Runnable {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A primitive method to check whether a server is already running on our port.
|
* Check whether a server port is available by trying to open a server socket
|
||||||
*/
|
*/
|
||||||
private static void checkPort(InetAddrPort addrPort) throws Exception {
|
private static void checkPort(InetAddrPort addrPort) throws Exception {
|
||||||
// checkRunning is disabled until we find a fix for the socket creation
|
|
||||||
// timeout problems reported on the list.
|
|
||||||
/*
|
|
||||||
InetAddress addr = addrPort.getInetAddress();
|
InetAddress addr = addrPort.getInetAddress();
|
||||||
|
int port = addrPort.getPort();
|
||||||
if (addr == null) {
|
if (addr == null) {
|
||||||
try {
|
try {
|
||||||
addr = InetAddress.getLocalHost();
|
addr = InetAddress.getLocalHost();
|
||||||
|
@ -386,19 +387,12 @@ public class Server implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Socket sock = new Socket();
|
ServerSocket sock = new ServerSocket(port, 1, addr);
|
||||||
// this should fix the timeout problems reported here:
|
sock.close();
|
||||||
// http://grazia.helma.at/pipermail/helma-user/2003-December/005602.html
|
|
||||||
sock.connect(new InetSocketAddress(addr, addrPort.getPort()), 1000);
|
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
// we couldn't connect to the socket because no server
|
throw new Exception("Error: Server already running on this port: " + addrPort);
|
||||||
// is running on it yet. Everything's ok.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
// if we got so far, another server is already running on this port and db
|
|
||||||
throw new Exception("Error: Server already running on this port: " + addrPort);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue