mirror of https://github.com/apache/cassandra
fix race in TcpConnection. patch by Jun Rao; reviewed by jbellis for CASSANDRA-220
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/branches/cassandra-0.3@782656 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e43f5a073
commit
629b696491
|
|
@ -425,30 +425,30 @@ public class TcpConnection extends SelectionKeyHandler implements Comparable
|
|||
|
||||
void doPendingWrites()
|
||||
{
|
||||
try
|
||||
{
|
||||
while(!pendingWrites_.isEmpty())
|
||||
{
|
||||
ByteBuffer buffer = pendingWrites_.get(0);
|
||||
socketChannel_.write(buffer);
|
||||
if (buffer.remaining() > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pendingWrites_.remove(0);
|
||||
}
|
||||
|
||||
}
|
||||
catch(IOException ex)
|
||||
synchronized(this)
|
||||
{
|
||||
logger_.warn(LogUtil.throwableToString(ex));
|
||||
// This is to fix the wierd Linux bug with NIO.
|
||||
errorClose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
synchronized(this)
|
||||
try
|
||||
{
|
||||
while(!pendingWrites_.isEmpty())
|
||||
{
|
||||
ByteBuffer buffer = pendingWrites_.get(0);
|
||||
socketChannel_.write(buffer);
|
||||
if (buffer.remaining() > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pendingWrites_.remove(0);
|
||||
}
|
||||
|
||||
}
|
||||
catch(IOException ex)
|
||||
{
|
||||
logger_.warn(LogUtil.throwableToString(ex));
|
||||
// This is to fix the wierd Linux bug with NIO.
|
||||
errorClose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!pendingWrites_.isEmpty())
|
||||
{
|
||||
key_.interestOps(key_.interestOps() | SelectionKey.OP_WRITE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue