Cleaning up ChannelContext between HTTP requests

"Trustin Lee (이희승)" trustin at gmail.com
Mon Jan 25 04:12:57 EST 2010


Hi,

That's weird.  The ChannelFuture for a write request is always notified
immediately on successful complete write and messageReceived is not
triggered until your future listener returns the control to the I/O thread.

Could you please write a simple application that demonstrates the
problem?  Then I could confirm if this is a bug in Netty or not and fix
the problem.

Thanks,
Truatin

danotsky wrote:
> I've got an HTTP server setup on Netty.  Upon receiving each HTTP request I'm
> creating a new context and attaching it to the Channel.  When writing the
> response, I add a listener to the write future that does some bookkeeping
> and then clears the context and leaves the channel ready for the next
> request.  For now I'm preventing multiple outstanding requests (pipelining)
> by closing the connection when a new request comes in before the previous
> request has cleaned up.  
> 
> The problem I'm running into is that occasionally when sending serial
> requests over a single connection, a new request comes in before the
> previous was cleaned up.  I assumed that that a future listener setup on the
> response write would always execute before a message received event occurred
> for the next request, but this appears to not be the case since occasionally
> the next request comes in before the write future is executed.  
> 
> I control the client in this case and I know that it's not sending the next
> request until it fully reads the previous response, so it really is a race
> condition in the server.  
> 
> Is this behavior behavior expected or might it be a bug?  If it's expected,
> what's the best way to handle this?  I don't seem to have a way to cleanup
> after a write completes in a spot where I know it's before the next request
> is read.
> 
> Thanks.
> 
> 

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100125/c2eab6e5/attachment-0001.bin 


More information about the netty-users mailing list