diff options
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPSession.java')
-rw-r--r-- | src/main/java/com/lumaserv/bgp/BGPSession.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPSession.java b/src/main/java/com/lumaserv/bgp/BGPSession.java index 9de32ab..d51a83e 100644 --- a/src/main/java/com/lumaserv/bgp/BGPSession.java +++ b/src/main/java/com/lumaserv/bgp/BGPSession.java @@ -39,21 +39,21 @@ public class BGPSession implements Runnable { @Getter byte[] remoteIdentifier; - public BGPSession(BGPServer server, Socket socket, BGPSessionConfiguration configuration, BGPFsm fsm) throws IOException { + public BGPSession(BGPServer server, Socket socket, BGPSessionConfiguration configuration) throws IOException { this.server = server; this.configuration = configuration; this.socket = socket; this.inputStream = socket.getInputStream(); this.outputStream = socket.getOutputStream(); - this.fsm = fsm; + this.fsm = new BGPFsm(this); this.host = null; this.port = -1; } - public BGPSession(BGPServer server, BGPSessionConfiguration configuration, BGPFsm fsm, String host, int port) throws IOException { + public BGPSession(BGPServer server, BGPSessionConfiguration configuration, String host, int port) throws IOException { this.server = server; this.configuration = configuration; - this.fsm = fsm; + this.fsm = new BGPFsm(this); this.host = host; this.port = port; } @@ -68,6 +68,11 @@ public class BGPSession implements Runnable { protected void finalize() throws Throwable { System.out.println("Finalize BGPSession"); + super.finalize(); + } + + public void cleanup() { + fsm.cleanup(); } public void automaticStop() { @@ -106,7 +111,7 @@ public class BGPSession implements Runnable { } catch(IOException ex) { } dropConnection(); - // TODO Break links between fsm and session! + cleanup(); } else { isAS4Capability = isAdvAS4Capability && open.getAS4Capability().isPresent(); remoteIdentifier = open.getIdentifier(); @@ -224,7 +229,6 @@ System.out.println("Sent open"); } catch (IOException ex) { if (!closed) { fsm.getCurrentState().tcpConnectionFails(); - ex.printStackTrace(); } closed = true; configuration.getListener().onClose(this); |