Fix unreleased resource sockets

patch by Arunkumar M; reviewed by yukim for CASSANDRA-12330
This commit is contained in:
Arunkumar M 2016-08-11 22:34:14 -07:00 committed by Yuki Morishita
parent 86a73d439c
commit 83cc2ed3af
2 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
3.0.10
* Fix potential socket leak (CASSANDRA-12329)
* Fix potential socket leak (CASSANDRA-12329, CASSANDRA-12330)
* Fix ViewTest.testCompaction (CASSANDRA-12789)
* Improve avg aggregate functions (CASSANDRA-12417)
* Preserve quoted reserved keyword column names in MV creation (CASSANDRA-11803)

View File

@ -47,15 +47,24 @@ public class DefaultConnectionFactory implements StreamConnectionFactory
int attempts = 0;
while (true)
{
Socket socket = null;
try
{
Socket socket = OutboundTcpConnectionPool.newSocket(peer);
socket = OutboundTcpConnectionPool.newSocket(peer);
socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout());
socket.setKeepAlive(true);
return socket;
}
catch (IOException e)
{
if (socket != null)
{
try
{
socket.close();
}
catch (IOException ignore) {}
}
if (++attempts >= MAX_CONNECT_ATTEMPTS)
throw e;