Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix for non-closing client sessions

orbiterd352853f2de7
diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java
index f98ae8f06..55df8c855 100644
--- a/source/de/anomic/http/httpc.java
+++ b/source/de/anomic/http/httpc.java
@@ -365,7 +365,7 @@ public final class httpc {
// setting socket timeout and keep alive behaviour
this.socket.setSoTimeout(timeout); // waiting time for read
//socket.setSoLinger(true, timeout);
- this.socket.setKeepAlive(true); //
+ this.socket.setKeepAlive(false); //
if (incomingByteCountAccounting != null) {
this.clientInputByteCount = new httpdByteCountInputStream(this.socket.getInputStream(),incomingByteCountAccounting);
@@ -374,7 +374,6 @@ public final class httpc {
this.clientOutputByteCount = new httpdByteCountOutputStream(this.socket.getOutputStream(),outgoingByteCountAccounting);
}
-
// getting input and output streams
this.clientInput = new PushbackInputStream((this.clientInputByteCount!=null)?
this.clientInputByteCount:
@@ -400,19 +399,58 @@ public final class httpc {
return (this.clientOutputByteCount == null)?0:this.clientOutputByteCount.getCount();
}
+ public void finalize() {
+ this.close();
+ }
+
public void close() {
+ if (this.clientInput != null) {
+ try {this.clientInput.close();} catch (Exception e) {}
+ this.clientInput = null;
+ }
+
+ if (this.clientOutput != null) {
+ try {this.clientOutput.close();} catch (Exception e) {}
+ this.clientOutput = null;
+ }
+
+ if (this.socket != null) {
+ try {this.socket.close();} catch (Exception e) {}
+ httpc.unregisterOpenSocket(this.socket, this.socketOwner);
+ this.socket = null;
+ }
+ this.socketOwner = null;
+
+ if (this.clientInputByteCount != null) {
+ this.clientInputByteCount.finish();
+ this.clientInputByteCount = null;
+ }
+
+ if (this.clientOutputByteCount != null) {
+ this.clientOutputByteCount.finish();
+ this.clientOutputByteCount = null;
+ }
+
+ this.adressed_host = null;
+ this.target_virtual_host = null;
+
+ this.remoteProxyConfig = null;
+ this.requestPath = null;
}
/**
- * This method invokes a call to the given server.
- *
- * @param method Which method should be called? GET, POST, HEAD or CONNECT
- * @param path String with the path on the server to be get.
- * @param header The prefilled header (if available) from the calling
- * browser.
- * @param zipped Is encoded content (gzip) allowed or not?
- * @throws IOException
- */
+ * This method invokes a call to the given server.
+ *
+ * @param method
+ * Which method should be called? GET, POST, HEAD or CONNECT
+ * @param path
+ * String with the path on the server to be get.
+ * @param header
+ * The prefilled header (if available) from the calling browser.
+ * @param zipped
+ * Is encoded content (gzip) allowed or not?
+ * @throws IOException
+ */
private void send(String method, String path, httpHeader header, boolean zipped) throws IOException {
// scheduled request through request-response objects/threads