Hello,
I have a problem with NIO connector in mina 2.0 M4 when handling many
simultaneous connections - sometimes after calling connect() I do not
receive sessionCreated() callback.
I am trying to prepare a small test, but I can not reproduce the problem
in this test yet, so I tried to investigate mina sources myself using
out working system.
I can see that a new Channel is always created, channel.connect() is
called, SYN, SYN-ACK, ACK are sent, then I see that
AbstractPollingIoConnector.Connector registers the new channel in
Selector, but after that AbstractPollingIoConnector.Connector is stopped
because nHandles=0 and connectQueue is already empty (no more connection
requests).
I mean the following code in AbstractPollingIoConnector.Connector.run():
if (nHandles == 0) {
synchronized (lock) {
if (connectQueue.isEmpty()) {
connector = null;
break;
}
}
}
After that, 'select' is not called on the Selector anymore for this
session.
One reason of this behavior (which I can assume now) is 'nHandles'
variable initialized outside of 'while' loop. Maybe, it should be
initialized on each iteration? So every time we calculate the number of
new sessions, canceled sessions, etc.
In my situation, nHandles=-1, then, after registering the new session,
nHandles becomes 0 and the Connector.run() is stopped.
Victor N