Fixed a bug where DiscardClient didn't work since the last optimization

This commit is contained in:
Trustin Lee 2008-09-26 09:04:02 +00:00
parent 39086edae6
commit 362ecf640b

View File

@ -318,14 +318,17 @@ class NioWorker implements Runnable {
static void write(final NioSocketChannel channel, boolean mightNeedWakeup) { static void write(final NioSocketChannel channel, boolean mightNeedWakeup) {
if (mightNeedWakeup) { if (mightNeedWakeup) {
NioWorker worker = channel.getWorker(); NioWorker worker = channel.getWorker();
if (worker != null && Thread.currentThread() != worker.thread) { if (worker != null) {
if (channel.writeTaskInTaskQueue.compareAndSet(false, true)) { Thread workerThread = worker.thread;
worker.taskQueue.offer(channel.writeTask); if (workerThread != null && Thread.currentThread() != workerThread) {
if (channel.writeTaskInTaskQueue.compareAndSet(false, true)) {
worker.taskQueue.offer(channel.writeTask);
}
if (worker.wakenUp.compareAndSet(false, true)) {
worker.selector.wakeup();
}
return;
} }
if (worker.wakenUp.compareAndSet(false, true)) {
worker.selector.wakeup();
}
return;
} }
} }
@ -367,7 +370,6 @@ class NioWorker implements Runnable {
if (internalWriteBuffer.isEmpty()) { if (internalWriteBuffer.isEmpty()) {
channel.writeBuffer.drainTo(internalWriteBuffer); channel.writeBuffer.drainTo(internalWriteBuffer);
} }
evt = channel.currentWriteEvent; evt = channel.currentWriteEvent;
for (;;) { for (;;) {
if (evt == null) { if (evt == null) {