UPnP: Remove finalize() in HTTPSocket (ticket #2490)

This commit is contained in:
zzz
2019-05-02 14:08:25 +00:00
parent bb86c56e77
commit b9726a0af8
4 changed files with 25 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
2019-05-02 zzz 2019-05-02 zzz
* GeoIP Maxmind 2019-04-29 * GeoIP Maxmind 2019-04-29
* NTCP: Rare EventPumper 100% CPU fix (ticket #2476) * NTCP: Rare EventPumper 100% CPU fix (ticket #2476)
* UPnP: Remove finalize() in HTTPSocket (ticket #2490)
2019-04-25 zzz 2019-04-25 zzz
* Build: Drop unmaintained sample apparmor script (ticket #2319) * Build: Drop unmaintained sample apparmor script (ticket #2319)

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 10; public final static long BUILD = 11;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";

View File

@@ -40,15 +40,18 @@ public class HTTPServerThread extends Thread
public void run() public void run()
{ {
HTTPSocket httpSock = new HTTPSocket(sock); HTTPSocket httpSock = new HTTPSocket(sock);
if (httpSock.open() == false) try {
return; if (httpSock.open() == false)
HTTPRequest httpReq = new HTTPRequest(); return;
httpReq.setSocket(httpSock); HTTPRequest httpReq = new HTTPRequest();
while (httpReq.read() == true) { httpReq.setSocket(httpSock);
httpServer.performRequestListener(httpReq); while (httpReq.read() == true) {
if (httpReq.isKeepAlive() == false) httpServer.performRequestListener(httpReq);
break; if (httpReq.isKeepAlive() == false)
break;
}
} finally {
httpSock.close();
} }
httpSock.close();
} }
} }

View File

@@ -27,6 +27,7 @@
package org.cybergarage.http; package org.cybergarage.http;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.Socket; import java.net.Socket;
@@ -51,11 +52,6 @@ public class HTTPSocket
setOutputStream(socket.getOutputStream()); setOutputStream(socket.getOutputStream());
} }
public void finalize()
{
close();
}
//////////////////////////////////////////////// ////////////////////////////////////////////////
// Socket // Socket
//////////////////////////////////////////////// ////////////////////////////////////////////////
@@ -133,17 +129,18 @@ public class HTTPSocket
public boolean close() public boolean close()
{ {
try { if (sockIn != null)
if (sockIn != null) try {
sockIn.close(); sockIn.close();
if (sockOut != null) } catch (IOException e) {}
if (sockOut != null)
try {
sockOut.close(); sockOut.close();
getSocket().close(); } catch (IOException e) {}
} if (socket != null)
catch (Exception e) { try {
//Debug.warning(e); socket.close();
return false; } catch (IOException e) {}
}
return true; return true;
} }