Tiny code clean up

This commit is contained in:
Trustin Lee 2010-02-19 00:03:33 +00:00
parent 545acfdf42
commit cee5f945dc
2 changed files with 7 additions and 6 deletions

View File

@ -499,6 +499,7 @@ class NioDatagramWorker implements Runnable {
int writtenBytes = 0;
final DatagramChannel ch = channel.getDatagramChannel();
final Queue<MessageEvent> writeBuffer = channel.writeBufferQueue;
final int writeSpinCount = channel.getConfig().getWriteSpinCount();
synchronized (channel.writeLock) {
@ -524,11 +525,10 @@ class NioDatagramWorker implements Runnable {
try {
int localWrittenBytes = 0;
java.nio.channels.DatagramChannel dch = channel.getDatagramChannel();
SocketAddress raddr = evt.getRemoteAddress();
if (raddr == null) {
for (int i = writeSpinCount; i > 0; i --) {
localWrittenBytes = dch.write(buf);
localWrittenBytes = ch.write(buf);
if (localWrittenBytes != 0) {
writtenBytes += localWrittenBytes;
break;
@ -536,7 +536,7 @@ class NioDatagramWorker implements Runnable {
}
} else {
for (int i = writeSpinCount; i > 0; i --) {
localWrittenBytes = dch.send(buf, raddr);
localWrittenBytes = ch.send(buf, raddr);
if (localWrittenBytes != 0) {
writtenBytes += localWrittenBytes;
break;

View File

@ -24,9 +24,9 @@ import java.nio.channels.AsynchronousCloseException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.ScatteringByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Queue;
import java.util.Set;
@ -304,7 +304,7 @@ class NioWorker implements Runnable {
}
private boolean read(SelectionKey k) {
ScatteringByteChannel ch = (ScatteringByteChannel) k.channel();
SocketChannel ch = (SocketChannel) k.channel();
NioSocketChannel channel = (NioSocketChannel) k.attachment();
ReceiveBufferSizePredictor predictor =
@ -452,6 +452,7 @@ class NioWorker implements Runnable {
int writtenBytes = 0;
final SocketChannel ch = channel.socket;
final Queue<MessageEvent> writeBuffer = channel.writeBuffer;
final int writeSpinCount = channel.getConfig().getWriteSpinCount();
synchronized (channel.writeLock) {
@ -474,7 +475,7 @@ class NioWorker implements Runnable {
try {
for (int i = writeSpinCount; i > 0; i --) {
int localWrittenBytes = channel.socket.write(buf);
int localWrittenBytes = ch.write(buf);
if (localWrittenBytes != 0) {
writtenBytes += localWrittenBytes;
break;