Unfortunately, even with the patch in Connector and Processor, the
problem is reproduced randomly, most of time everything works, but
sometimes I see that sessionCreated is not called. But if I start a new
connection, this "old" pending connection (for which I am waiting for
sessionCreated callback) is completed instantly, so I get sessionCreated.
Victor N
Victor wrote:
I have added a similar fix in AbstractPollingIoProcessor.Processor.run()
- nSessions is now initialized inside the loop, on each iteration.
It seems to work now, I can not reproduce the bug, but I will continue
testing.
Not sure whether this patch is adequate or nor. Any comments?
Victor N
Victor wrote:
I tried to play with my fix - from the first glance, it seemed to work
- connection was established, sessionCreated was called,
but at the second attempt the problem reproduced.
Any ideas what is wrong here?
Thanks,
Victor N
Victor wrote:
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