Skip to content

Commit

Permalink
Closing the socket if connect() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Jan 25, 2012
1 parent 02898d9 commit c9e6926
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/org/jgroups/blocks/TCPConnectionMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,20 @@ public class TCPConnection implements Connection {
if(peer_addr == null)
throw new IllegalArgumentException("Invalid parameter peer_addr="+ peer_addr);
SocketAddress destAddr=new InetSocketAddress(((IpAddress)peer_addr).getIpAddress(),((IpAddress)peer_addr).getPort());
this.sock=socket_factory.createSocket(Global.TCP_SOCK);
this.sock.bind(new InetSocketAddress(bind_addr, 0));
Util.connect(this.sock, destAddr, sock_conn_timeout);
this.sock=socket_factory.createSocket("jgroups.tcp.sock");
try {
this.sock.bind(new InetSocketAddress(bind_addr, 0));
Util.connect(this.sock, destAddr, sock_conn_timeout);
}
catch(Exception t) {
socket_factory.close(this.sock);
throw t;
}
setSocketParameters(sock);
this.out=new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
this.in=new DataInputStream(new BufferedInputStream(sock.getInputStream()));
sendLocalAddress(getLocalAddress());
this.peer_addr=peer_addr;
this.peer_addr=peer_addr;
}

TCPConnection(Socket s) throws Exception {
Expand Down

0 comments on commit c9e6926

Please sign in to comment.