Author: fuchsi Date: 2007-10-03 14:18:26 +0200 (Wed, 03 Oct 2007) New Revision: 4132
Modified: trunk/source/de/anomic/http/httpc.java Log: Make sure that sockets which couldn't be opened aren't handled as active connections, in which case they wouldn't be closed. Please test this and report any problems (connections that stay open for a very long time according to http://<your_yacy_peed>/Connections_p.html to http://forum.yacy-websuche.de/viewtopic.php?f=5&t=386 Modified: trunk/source/de/anomic/http/httpc.java =================================================================== --- trunk/source/de/anomic/http/httpc.java 2007-10-03 04:00:52 UTC (rev 4131) +++ trunk/source/de/anomic/http/httpc.java 2007-10-03 12:18:26 UTC (rev 4132) @@ -227,8 +227,9 @@ String outgoingByteCountAccounting ) throws IOException { + // TODO method can be removed completely when no more CLOSE_WAIT connections appear. // remove old connections - checkIdleConnections(); + //checkIdleConnections(); // register new connection this.hashIndex = objCounter; @@ -390,13 +391,9 @@ // trying to establish a connection to the address this.initTime = System.currentTimeMillis(); + this.socket.setKeepAlive(false); // this.socket.connect(address, timeout); - // setting socket timeout and keep alive behaviour - this.socket.setSoTimeout(timeout); // waiting time for read - //socket.setSoLinger(true, timeout); - this.socket.setKeepAlive(false); // - if (incomingByteCountAccounting != null) { this.clientInputByteCount = new httpdByteCountInputStream(this.socket.getInputStream(),incomingByteCountAccounting); } @@ -418,6 +415,14 @@ } this.socket = null; throw new IOException("unknown host: " + server); + } catch (IOException e) { + // There was an error while connecting the socket, probably a SocketTimeoutException + // we have to close the httpc, otherwise it would stay in activeConnections forever + serverLog.logFine("HTTPC", "Couldn't open socket to: " + this.adressed_host + ":" + this.adressed_port); + close(); + + // TODO do we need to hand it over to the caller? + throw e; } } @@ -429,6 +434,7 @@ return (this.clientOutputByteCount == null)?0:this.clientOutputByteCount.getCount(); } + // TODO remove when it's sure that the CLOSE_WAIT problem was solved. 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 @@ -508,7 +514,7 @@ public void close() { synchronized (activeConnections) {activeConnections.remove(this);} - //System.out.println("*** DEBUG close httpc: " + activeConnections.size() + " connections online"); + System.out.println("*** DEBUG close httpc: " + activeConnections.size() + " connections online"); if (this.clientInput != null) { try {this.clientInput.close();} catch (Exception e) {} _______________________________________________ YaCy-svn mailing list [email protected] https://lists.berlios.de/mailman/listinfo/yacy-svn
