Skip to content

Commit

Permalink
netty: fix a race for channelz at server transport creation
Browse files Browse the repository at this point in the history
  • Loading branch information
dapengzhang0 committed Jan 15, 2020
1 parent 1b5d61f commit a4077bf
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions netty/src/main/java/io/grpc/netty/NettyServer.java
Expand Up @@ -251,19 +251,10 @@ public void operationComplete(ChannelFuture future) throws Exception {
throw new IOException("Failed to bind", future.cause());
}
channel = future.channel();
Future<?> channelzFuture = channel.eventLoop().submit(new Runnable() {
@Override
public void run() {
InternalInstrumented<SocketStats> listenSocket = new ListenSocket(channel);
listenSocketStats.set(listenSocket);
channelz.addListenSocket(listenSocket);
}
});
try {
channelzFuture.await();
} catch (InterruptedException ex) {
throw new RuntimeException("Interrupted while registering listen socket to channelz", ex);
}

InternalInstrumented<SocketStats> listenSocket = new ListenSocket(channel);
listenSocketStats.set(listenSocket);
channelz.addListenSocket(listenSocket);
}

@Override
Expand Down

0 comments on commit a4077bf

Please sign in to comment.