Author: elecharny
Date: Wed Feb 10 22:03:55 2010
New Revision: 908669
URL: http://svn.apache.org/viewvc?rev=908669&view=rev
Log:
Fix for DIRMINA-762
Modified:
mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
Modified:
mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java?rev=908669&r1=908668&r2=908669&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/core/polling/AbstractPollingIoProcessor.java
Wed Feb 10 22:03:55 2010
@@ -1064,35 +1064,39 @@
long t1 = System.currentTimeMillis();
long delta = (t1 - t0);
- synchronized (wakeupCalled) {
- if ((selected == 0) && !wakeupCalled.get() && (delta <
100)) {
- // Last chance : the select() may have been
- // interrupted because we have had an closed
channel.
- if (isBrokenConnection()) {
- // we can reselect immediately
- continue;
- } else {
- LOG.warn("Create a new selector. Selected is
0, delta = "
- + (t1 - t0));
- // Ok, we are hit by the nasty epoll
- // spinning.
- // Basically, there is a race condition
- // which causes a closing file descriptor not
to be
- // considered as available as a selected
channel, but
- // it stopped the select. The next time we will
- // call select(), it will exit immediately for
the same
- // reason, and do so forever, consuming 100%
- // CPU.
- // We have to destroy the selector, and
- // register all the socket on a new one.
- registerNewSelector();
- }
+ if ((selected == 0) && !wakeupCalled.get() && (delta <
100)) {
+ // Last chance : the select() may have been
+ // interrupted because we have had an closed channel.
+ if (isBrokenConnection()) {
+ LOG.warn("Broken connection");
+
+ // we can reselect immediately
+ // set back the flag to false
+ wakeupCalled.getAndSet(false);
- // and continue the loop
continue;
+ } else {
+ LOG.warn("Create a new selector. Selected is 0,
delta = "
+ + (t1 - t0));
+ // Ok, we are hit by the nasty epoll
+ // spinning.
+ // Basically, there is a race condition
+ // which causes a closing file descriptor not to be
+ // considered as available as a selected channel,
but
+ // it stopped the select. The next time we will
+ // call select(), it will exit immediately for the
same
+ // reason, and do so forever, consuming 100%
+ // CPU.
+ // We have to destroy the selector, and
+ // register all the socket on a new one.
+ registerNewSelector();
}
+ // Set back the flag to false
wakeupCalled.getAndSet(false);
+
+ // and continue the loop
+ continue;
}
// Manage newly created session first
Modified:
mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java?rev=908669&r1=908668&r2=908669&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio/NioProcessor.java
Wed Feb 10 22:03:55 2010
@@ -43,7 +43,7 @@
*/
public final class NioProcessor extends AbstractPollingIoProcessor<NioSession>
{
/** The selector associated with this processor */
- private volatile Selector selector;
+ private Selector selector;
/**
*
@@ -84,10 +84,8 @@
@Override
protected void wakeup() {
- synchronized (wakeupCalled) {
- wakeupCalled.getAndSet(true);
- selector.wakeup();
- }
+ wakeupCalled.getAndSet(true);
+ selector.wakeup();
}
@Override