You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by boB Gage <bg...@ekosystems.com> on 2008/12/30 22:24:30 UTC

Thread issue

I think I've discovered the root cause to the problems I'm having (see 
previous messages).  

I've changed from MessageDecoder objects to ProtocolDecoder objects so I 
could descend from CumulativeProtocolDecoder and get complete packets 
even if they are sent in distinct chunks.   This has not helped.

My data simulator object launches a thread that occasionally (every 
250ms) checks conditions and calls session.write() if appropriate to 
provide data to the rest of my program.

The debug log shows that the thread launched to generate data (ie the 
one doing the session.write()s) is the same thread doing the decoding.   

So, when my data provider thread issues a session.write() with the first 
piece of the broken packet, it is that thread that 
CumulativeProtocolDecoder calls my doDecode() method from.   
Unfortunately, the thread is never released again as 
CumulativeProtocolDecoder just keeps calling my descendant's doDecode() 
method over and over, apparently expecting more data to show up.

Since this is tying up the thread that would be generating the data, the 
looping is endless.   Somehow issuing a session.write() call allowed 
Mina to hijack my thread into it's now endless decoding loop...

IOW.... My thread was stolen by the far end of my VmPipe connection, so 
it's no big surprise that an incomplete packet locks everything into an 
endless loop.  

I see two big bugs here, and both look like Mina problems to my eyes:
  1) A session.write() call [on a VmPipe] enables thread stealing
  2) CumulativeProtocolDecoder calls doDecode() even if no new data has 
been received since the last call.


Any help would be greatly appreciated,
boB