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
* GeoIP Maxmind 2019-04-29
* NTCP: Rare EventPumper 100% CPU fix (ticket #2476)
* UPnP: Remove finalize() in HTTPSocket (ticket #2490)
2019-04-25 zzz
* Build: Drop unmaintained sample apparmor script (ticket #2319)

View File

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

View File

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

View File

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