Skip to content

Commit

Permalink
Backport DIRMINA-1095 from 2.1.X
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-valliere committed May 4, 2019
1 parent 1931add commit 5f3a628
Showing 1 changed file with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,34 @@ private int registerHandles() {
}

private void processReadySessions(Set<SelectionKey> handles) {
Iterator<SelectionKey> iterator = handles.iterator();

while (iterator.hasNext()) {
SelectionKey key = iterator.next();
DatagramChannel handle = (DatagramChannel) key.channel();
iterator.remove();

try {
if (key.isValid() && key.isReadable()) {
readHandle(handle);
}

if (key.isValid() && key.isWritable()) {
for (IoSession session : getManagedSessions().values()) {
scheduleFlush((NioSession) session);
}
}
} catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
}
}
final Iterator<SelectionKey> iterator = handles.iterator();

while (iterator.hasNext()) {
try {
final SelectionKey key = iterator.next();
final DatagramChannel handle = (DatagramChannel) key.channel();

if (key.isValid()) {
if (key.isReadable()) {
readHandle(handle);
}

if (key.isWritable()) {
for (IoSession session : getManagedSessions().values()) {
final NioSession x = (NioSession) session;
if (x.getChannel() == handle) {
scheduleFlush(x);
}
}
}
}

} catch (Exception e) {
ExceptionMonitor.getInstance().exceptionCaught(e);
} finally {
iterator.remove();
}
}
}

private boolean scheduleFlush(NioSession session) {
Expand Down

0 comments on commit 5f3a628

Please sign in to comment.