Deadlock after adding ExecutionHandler

IanS iswett at yahoo.com
Mon Jul 26 15:39:18 EDT 2010


I had this happen again today and I believe I figured out what is causing it
on the Netty side.

I believe the reason is that Semaphore.release() only releases one thread,
but there were multiple waiting, and the others may never got released only
if the object sizes vary.

This is because it it is possible two threads with relatively small messages
could be waiting, but then a large message finishes, and that only calls
release() on one of the threads, and after that, we're back below the
maxTotalMemorySize, so release() isn't going to get called again.

I'm not sure my solution is the best, but this does work in my case.

After semaphore.release() in MemoryAwareThreadPoolExecutor.java, I added:

	if(totalCounter < maxTotalMemorySize) {
        		while(semaphore.hasQueuedThreads()) {
        			semaphore.release();
        		}
        	}

Hopefully, this or something similar is a worthwhile change?

Ian
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Deadlock-after-adding-ExecutionHandler-tp5237295p5339464.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list