summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2014-11-13 21:21:25 -0500
committerBrian P. Hinz <bphinz@users.sf.net>2014-11-13 21:21:25 -0500
commit12c358230645ca37e438941f61ff00acfe251c54 (patch)
treedd8bba292703e31be8d16f9c7abccd1460b8705d
parenta9595fbf79b631f02b47bcf117b508e9de93659f (diff)
downloadtigervnc-12c358230645ca37e438941f61ff00acfe251c54.tar.gz
tigervnc-12c358230645ca37e438941f61ff00acfe251c54.zip
Make sure sockets are shutdown in java viewer listen mode
The finalizer method may not be strictly necessary but for the sake of consistency shutdown the socket listener the same way we do for a regular TcpSocket.
-rw-r--r--java/com/tigervnc/network/SocketListener.java2
-rw-r--r--java/com/tigervnc/network/TcpListener.java19
2 files changed, 15 insertions, 6 deletions
diff --git a/java/com/tigervnc/network/SocketListener.java b/java/com/tigervnc/network/SocketListener.java
index 6401c2cc..a1f5ea1b 100644
--- a/java/com/tigervnc/network/SocketListener.java
+++ b/java/com/tigervnc/network/SocketListener.java
@@ -29,7 +29,7 @@ abstract public class SocketListener {
public SocketListener() {}
// shutdown() stops the socket from accepting further connections
- abstract public void shutdown();
+ abstract public void shutdown() throws Exception;
// accept() returns a new Socket object if there is a connection
// attempt in progress AND if the connection passes the filter
diff --git a/java/com/tigervnc/network/TcpListener.java b/java/com/tigervnc/network/TcpListener.java
index b66558b9..6170a602 100644
--- a/java/com/tigervnc/network/TcpListener.java
+++ b/java/com/tigervnc/network/TcpListener.java
@@ -84,12 +84,21 @@ public class TcpListener extends SocketListener {
this(listenaddr, port, false, null, true);
}
-// TcpListener::~TcpListener() {
-// if (closeFd) closesocket(fd);
-// }
+ protected void finalize() throws Exception {
+ if (closeFd)
+ try {
+ ((SocketDescriptor)getFd()).close();
+ } catch (IOException e) {
+ throw new Exception(e.getMessage());
+ }
+ }
- public void shutdown() {
- //shutdown(getFd(), 2);
+ public void shutdown() throws Exception {
+ try {
+ ((SocketDescriptor)getFd()).shutdown();
+ } catch (IOException e) {
+ throw new Exception(e.getMessage());
+ }
}
public TcpSocket accept() {