File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
netty/src/main/java/io/grpc/netty Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -123,13 +123,6 @@ public void start(ServerListener serverListener) throws IOException {
123123 b .childHandler (new ChannelInitializer <Channel >() {
124124 @ Override
125125 public void initChannel (Channel ch ) throws Exception {
126- eventLoopReferenceCounter .retain ();
127- ch .closeFuture ().addListener (new ChannelFutureListener () {
128- @ Override
129- public void operationComplete (ChannelFuture future ) {
130- eventLoopReferenceCounter .release ();
131- }
132- });
133126 NettyServerTransport transport = new NettyServerTransport (ch , protocolNegotiator ,
134127 maxStreamsPerConnection , flowControlWindow , maxMessageSize , maxHeaderListSize );
135128 ServerTransportListener transportListener ;
@@ -140,6 +133,15 @@ public void operationComplete(ChannelFuture future) {
140133 ch .close ();
141134 return ;
142135 }
136+ // `channel` shutdown can race with `ch` initialization, so this is only safe to increment
137+ // inside the lock.
138+ eventLoopReferenceCounter .retain ();
139+ ch .closeFuture ().addListener (new ChannelFutureListener () {
140+ @ Override
141+ public void operationComplete (ChannelFuture future ) {
142+ eventLoopReferenceCounter .release ();
143+ }
144+ });
143145
144146 transportListener = listener .transportCreated (transport );
145147 }
You can’t perform that action at this time.
0 commit comments