← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/turnip:loseWriteConnection-test-failure into turnip:master

 

Colin Watson has proposed merging ~cjwatson/turnip:loseWriteConnection-test-failure into turnip:master.

Commit message:
Check if transport is connected before closing it

We've seen occasional test failures in `loseWriteConnection` calls for
some time because the socket had already been closed, and they've become
much more frequent of late.  Checking whether the transport is still
connected before telling it to lose its write connection should help.

LP: #1641100

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1641100 in turnip: "Occasional test failure in TestGitFrontendFunctional.test_clone_and_push"
  https://bugs.launchpad.net/turnip/+bug/1641100

For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/357691
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:loseWriteConnection-test-failure into turnip:master.
diff --git a/turnip/pack/git.py b/turnip/pack/git.py
index c18742f..d45e1db 100644
--- a/turnip/pack/git.py
+++ b/turnip/pack/git.py
@@ -381,7 +381,7 @@ class PackProxyServerProtocol(PackServerProtocol):
 
     def readConnectionLost(self):
         # Forward the closed stdin down the stack.
-        if self.peer is not None:
+        if self.peer is not None and self.peer.transport.connected:
             self.peer.transport.loseWriteConnection()
 
 
diff --git a/turnip/pack/ssh.py b/turnip/pack/ssh.py
index b753220..3526bb9 100644
--- a/turnip/pack/ssh.py
+++ b/turnip/pack/ssh.py
@@ -176,7 +176,8 @@ class SmartSSHSession(DoNothingSession):
             self.pack_protocol.transport.loseConnection()
 
     def eofReceived(self):
-        if self.pack_protocol is not None:
+        if (self.pack_protocol is not None and
+                self.pack_protocol.transport.connected):
             self.pack_protocol.transport.loseWriteConnection()
 
 

Follow ups