Created
December 9, 2011 08:43
-
-
Save jestan/1450770 to your computer and use it in GitHub Desktop.
sctp issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean scheduleWriteIfNecessary(final SctpChannelImpl channel) { | |
final Thread currentThread = Thread.currentThread(); | |
final Thread workerThread = thread; | |
if (currentThread != workerThread) { | |
if (channel.writeTaskInTaskQueue.compareAndSet(false, true)) { | |
boolean offered = writeTaskQueue.offer(channel.writeTask); | |
assert offered; | |
} | |
if (!(channel instanceof SctpAcceptedChannel) || | |
((SctpAcceptedChannel) channel).bossThread != currentThread) { | |
final Selector workerSelector = selector; | |
if (workerSelector != null) { | |
if (wakenUp.compareAndSet(false, true)) { | |
workerSelector.wakeup(); | |
} | |
} | |
} else { | |
// A write request can be made from an acceptor thread (boss) | |
// when a user attempted to write something in: | |
// | |
// * channelOpen() | |
// * channelBound() | |
// * channelConnected(). | |
// | |
// In this case, there's no need to wake up the selector because | |
// the channel is not even registered yet at this moment. | |
} | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-->
private final Queue registerTaskQueue = new ConcurrentBlockingQueue();
private final Queue writeTaskQueue = new ConcurrentBlockingQueue();