Possible small bug in Proxy Server example

aaron.riekenberg aaron.riekenberg at gmail.com
Sun Aug 8 07:26:29 EDT 2010


I think I may have found a small bug in the Proxy Server example code.

Suppose the following sequence of events happens:

1. A client connects to the proxy, so HexDumpProxyInboundHandler.channelOpen
is called.  channelOpen creates a new outbound channel for the connection
from the proxy to remote server for the client.  It schedules an
asynchronous connect of the outbound channel to the remote server.

2. Before the connect of the outbound channel finishes, the client's
connection to the proxy closes.  This causes
HexDumpProxyInboundHandler.channelClosed to be called.  channelClosed calls
closeOnFlush(outboundChannel).  closeOnFlush sees
outboundChannel.isConnected is false and does nothing.

3. The connect of the outbound channel finishes, so the anonymous
ChannelFutureListener.operationComplete is called.

If this sequence can really happen, it would result in an outbound channel
remaining open from the proxy to the remote server after the client
disconnected. Nothing would disconnect this channel until the remote server
decides to close the connection.

I have done some tests, and it seems the call to
inboundChannel.setReadable(false) in HexDumpProxyInboundHandler.channelOpen
suspends detection of the inbound channel closing, as well as read
operations.  So I have not been able to make step #2 happen before step #3
calls inboundChannel.setReadable(true).

Is it guaranteed that setReadable(false) will suspend detection of channel
closing/errors as well as reads?  Or I am I just getting lucky in my tests?
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Possible-small-bug-in-Proxy-Server-example-tp5385847p5385847.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list