@@ -515,21 +515,6 @@ public Runnable start(Listener listener) {
515
515
serializingExecutor .execute (new Runnable () {
516
516
@ Override
517
517
public void run () {
518
- // This is a hack to make sure the connection preface and initial settings to be sent out
519
- // without blocking the start. By doing this essentially prevents potential deadlock when
520
- // network is not available during startup while another thread holding lock to send the
521
- // initial preface.
522
- try {
523
- latch .await ();
524
- barrier .await (1000 , TimeUnit .MILLISECONDS );
525
- } catch (InterruptedException e ) {
526
- Thread .currentThread ().interrupt ();
527
- } catch (TimeoutException | BrokenBarrierException e ) {
528
- startGoAway (0 , ErrorCode .INTERNAL_ERROR , Status .UNAVAILABLE
529
- .withDescription ("Timed out waiting for second handshake thread. "
530
- + "The transport executor pool may have run out of threads" ));
531
- return ;
532
- }
533
518
// Use closed source on failure so that the reader immediately shuts down.
534
519
BufferedSource source = Okio .buffer (new Source () {
535
520
@ Override
@@ -549,6 +534,22 @@ public void close() {
549
534
Socket sock ;
550
535
SSLSession sslSession = null ;
551
536
try {
537
+ // This is a hack to make sure the connection preface and initial settings to be sent out
538
+ // without blocking the start. By doing this essentially prevents potential deadlock when
539
+ // network is not available during startup while another thread holding lock to send the
540
+ // initial preface.
541
+ try {
542
+ latch .await ();
543
+ barrier .await (1000 , TimeUnit .MILLISECONDS );
544
+ } catch (InterruptedException e ) {
545
+ Thread .currentThread ().interrupt ();
546
+ } catch (TimeoutException | BrokenBarrierException e ) {
547
+ startGoAway (0 , ErrorCode .INTERNAL_ERROR , Status .UNAVAILABLE
548
+ .withDescription ("Timed out waiting for second handshake thread. "
549
+ + "The transport executor pool may have run out of threads" ));
550
+ return ;
551
+ }
552
+
552
553
if (proxiedAddr == null ) {
553
554
sock = socketFactory .createSocket (address .getAddress (), address .getPort ());
554
555
} else {
@@ -1459,4 +1460,4 @@ public void alternateService(int streamId, String origin, ByteString protocol, S
1459
1460
// TODO(madongfly): Deal with alternateService propagation
1460
1461
}
1461
1462
}
1462
- }
1463
+ }
0 commit comments