mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
automatic deletion of dead client connections
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4110 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
49f1c58d64
commit
3c74014004
|
@ -249,7 +249,7 @@ public final class Connections_p {
|
|||
prop.put("clientList_" + c + "_clientProtocol", (clientConnection.ssl) ? "HTTPS" : "HTTP");
|
||||
prop.put("clientList_" + c + "_clientLifetime", System.currentTimeMillis() - clientConnection.initTime);
|
||||
prop.put("clientList_" + c + "_clientTargetHost", clientConnection.adressed_host + ":" + clientConnection.adressed_port);
|
||||
prop.put("clientList_" + c + "_clientCommand", clientConnection.command);
|
||||
prop.put("clientList_" + c + "_clientCommand", (clientConnection.command == null) ? "-" : clientConnection.command);
|
||||
prop.put("clientList_" + c + "_clientID", clientConnection.hashCode());
|
||||
c++;
|
||||
}
|
||||
|
|
|
@ -200,6 +200,7 @@ public final class httpc {
|
|||
public boolean ssl;
|
||||
public long initTime;
|
||||
public String command;
|
||||
public int timeout;
|
||||
|
||||
private int hashIndex;
|
||||
|
||||
|
@ -222,6 +223,10 @@ public final class httpc {
|
|||
String outgoingByteCountAccounting
|
||||
) throws IOException {
|
||||
|
||||
// remove old connections
|
||||
checkIdleConnections();
|
||||
|
||||
// register new connection
|
||||
this.hashIndex = objCounter;
|
||||
objCounter++;
|
||||
synchronized (activeConnections) {activeConnections.add(this);}
|
||||
|
@ -230,6 +235,7 @@ public final class httpc {
|
|||
this.ssl = ssl;
|
||||
this.initTime = System.currentTimeMillis();
|
||||
this.command = null;
|
||||
this.timeout = timeout;
|
||||
|
||||
if ((theRemoteProxyConfig == null) ||
|
||||
(!theRemoteProxyConfig.useProxy())) {
|
||||
|
@ -380,7 +386,7 @@ public final class httpc {
|
|||
}
|
||||
|
||||
// trying to establish a connection to the address
|
||||
this.socket.connect(address,timeout);
|
||||
this.socket.connect(address, timeout);
|
||||
|
||||
// registering the socket
|
||||
this.socketOwner = this.registerOpenSocket(this.socket);
|
||||
|
@ -422,6 +428,32 @@ public final class httpc {
|
|||
return (this.clientOutputByteCount == null)?0:this.clientOutputByteCount.getCount();
|
||||
}
|
||||
|
||||
public static int checkIdleConnections() {
|
||||
// try to find and close all connections that did not find a target server and are idle waiting for a server socket
|
||||
Iterator i = httpc.activeConnections.iterator();
|
||||
int c = 0;
|
||||
while (i.hasNext()) {
|
||||
httpc clientConnection = (httpc) i.next();
|
||||
if ((clientConnection.command == null) && (clientConnection.initTime + clientConnection.timeout > System.currentTimeMillis())) {
|
||||
// the time-out limit is reached. close the connection
|
||||
clientConnection.close();
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public static int closeAllConnections() {
|
||||
Iterator i = httpc.activeConnections.iterator();
|
||||
int c = 0;
|
||||
while (i.hasNext()) {
|
||||
httpc clientConnection = (httpc) i.next();
|
||||
clientConnection.close();
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public void finalize() {
|
||||
this.close();
|
||||
}
|
||||
|
|
|
@ -1785,6 +1785,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
|
|||
parser.close();
|
||||
plasmaHTCache.close();
|
||||
sbQueue.close();
|
||||
httpc.closeAllConnections();
|
||||
webStructure.flushCitationReference("crg");
|
||||
webStructure.close();
|
||||
log.logConfig("SWITCHBOARD SHUTDOWN STEP 3: sending termination signal to database manager (stand by...)");
|
||||
|
|
Loading…
Reference in New Issue
Block a user