mirror of https://github.com/grpc/grpc-java.git
Fix a deadlock in TransportSet.
Honor the lock order that transport lock > channel lock. Resolves #2246
This commit is contained in:
parent
8b745d9114
commit
3d4ae36074
|
|
@ -249,9 +249,14 @@ final class TransportSet implements WithLogId {
|
||||||
delayedTransport.endBackoff();
|
delayedTransport.endBackoff();
|
||||||
boolean shutdownDelayedTransport = false;
|
boolean shutdownDelayedTransport = false;
|
||||||
Runnable runnable = null;
|
Runnable runnable = null;
|
||||||
|
// TransportSet as a channel layer class should not call into transport methods while
|
||||||
|
// holding the lock, thus we call hasPendingStreams() outside of the lock. It will cause
|
||||||
|
// a _benign_ race where the TransportSet may transition to CONNECTING when there is not
|
||||||
|
// pending stream.
|
||||||
|
boolean hasPendingStreams = delayedTransport.hasPendingStreams();
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
reconnectTask = null;
|
reconnectTask = null;
|
||||||
if (delayedTransport.hasPendingStreams()) {
|
if (hasPendingStreams) {
|
||||||
// Transition directly to CONNECTING
|
// Transition directly to CONNECTING
|
||||||
runnable = startNewTransport(delayedTransport);
|
runnable = startNewTransport(delayedTransport);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue