why deadlock in my http proxy app
li wei
kouxing2000 at gmail.com
Fri Jan 29 05:37:40 EST 2010
hi
Is there somebody can help on this? give me some hint, why the dead lock
occour? Thanks.
Netty version: 3.2.0.ALPHA1 / 3.2.0.ALPHA3.
App: HttpProxy, One HttpServer + One HttpClient
Scenario: when HttpSerer receive a request from Client(web browser), in the
last handle of pipleline, firstly it invoke the HttpClient to build the
socket connection with the destination web server.(when it found the
connection is not ready)
ThreadMode: No ExecutorHandler, and the boss, worker threads are separated.
clientBootstrap = new ClientBootstrap(
new NioClientSocketChannelFactory(Executors
.newCachedThreadPool(),
Executors.newCachedThreadPool(), ioThreadNumber));
serverBootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(Executors
.newCachedThreadPool(),
Executors.newCachedThreadPool(), ioThreadNumber));
Code that throw exception:
SocketAddress remoteAddress = address.getNetworkAddress();
if (logger.isInfoEnabled()) {
logger.info("Going to connect:" + remoteAddress);
}
ChannelFuture cf = getClientBootstrap().connect(remoteAddress);
//Thread.sleep(1000);
boolean connectFinish = cf.await(connectTimeout_);
Question: So why deadlock? I am puzzled, in my mind, I don't think it is
possible for deadlock, the thread of HttpClient will not depend on the
thread of HttpServer.
And if I add Thread.sleep(1000) before await, the error will not occour
.
Looking forward for your help.
Exception Trace:
09:41:27,493 INFO [NioSocketIoServiceFactory] Going to
connect:web-proxy.fc.hp.com/16.213.0.40:8080
java.lang.IllegalStateException: await*() in I/O thread causes a dead lock
or sudden performance drop. Use addListener() instead or call await*() from
a different thread.
at
org.jboss.netty.channel.DefaultChannelFuture.checkDeadLock(DefaultChannelFuture.java:283)
at
org.jboss.netty.channel.DefaultChannelFuture.await0(DefaultChannelFuture.java:247)
at
org.jboss.netty.channel.DefaultChannelFuture.await(DefaultChannelFuture.java:188)
at
com.hp.atom.connector.socket.netty.SocketConnectionBuilder.connect(SocketConnectionBuilder.java:64)
at
com.hp.atom.connector.socket.netty.AbstractSocketPCSMManager.buildNetworkConnection(AbstractSocketPCSMManager.java:23)
at
com.hp.atom.connector.AbstractPCSMManager.connect(AbstractPCSMManager.java:82)
at com.hp.atom.http.HttpPCSMManager.send(HttpPCSMManager.java:84)
at com.hp.atom.http.example.Proxy$1.invoke(Proxy.java:45)
at
com.hp.atom.connector.socket.netty.EventHandler.messageReceived(EventHandler.java:31)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:79)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
at
com.hp.atom.connector.socket.netty.PCSMMaintainHandler.messageReceived(PCSMMaintainHandler.java:124)
at
org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:98)
at
org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler.handleUpstream(IdleStateAwareChannelHandler.java:48)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:358)
at
com.hp.atom.http.UpstreamTransformer.messageReceived(UpstreamTransformer.java:15)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:79)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
at
org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:101)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:79)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:391)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:506)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:490)
at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:427)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:79)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:796)
at
org.jboss.netty.handler.timeout.IdleStateHandler.messageReceived(IdleStateHandler.java:237)
at
org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:79)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:560)
at
org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:555)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:345)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:332)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:339)
at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:278)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:198)
at
org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
--
View this message in context: http://n2.nabble.com/why-deadlock-in-my-http-proxy-app-tp4479235p4479235.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list