diff --git twisted/conch/ssh/session.py twisted/conch/ssh/session.py
index c50372c..e315c8f 100755
|
|
class SSHSessionProcessProtocol(protocol.ProcessProtocol): |
188 | 188 | |
189 | 189 | def __init__(self, session): |
190 | 190 | self.session = session |
| 191 | self.lostOutOrErrFlag = False |
191 | 192 | |
192 | 193 | def connectionMade(self): |
193 | 194 | if self.session.buf: |
… |
… |
class SSHSessionProcessProtocol(protocol.ProcessProtocol): |
200 | 201 | def errReceived(self, err): |
201 | 202 | self.session.writeExtended(connection.EXTENDED_DATA_STDERR, err) |
202 | 203 | |
203 | | def inConnectionLost(self): |
204 | | self.session.conn.sendEOF(self.session) |
| 204 | def outConnectionLost(self): |
| 205 | """ |
| 206 | EOF should only be sent when both STDOUT and STDERR have been closed. |
| 207 | """ |
| 208 | if self.lostOutOrErrFlag is True: |
| 209 | self.session.conn.sendEOF(self.session) |
| 210 | else: |
| 211 | self.lostOutOrErrFlag = True |
| 212 | |
| 213 | def errConnectionLost(self): |
| 214 | """ |
| 215 | See outConnectionLost(). |
| 216 | """ |
| 217 | self.outConnectionLost() |
205 | 218 | |
206 | 219 | def connectionLost(self, reason = None): |
207 | 220 | self.session.loseConnection() |
diff --git twisted/conch/test/test_session.py twisted/conch/test/test_session.py
index f59fd72..e901913 100644
|
|
class SSHSessionProcessProtocolTestCase(unittest.TestCase): |
1113 | 1113 | [(1, 'test data')]) |
1114 | 1114 | |
1115 | 1115 | |
1116 | | def test_inConnectionLost(self): |
| 1116 | def test_outConnectionLost(self): |
1117 | 1117 | """ |
1118 | | When inConnectionLost is called, it should send an EOF message, |
| 1118 | When outConnectionLost and errConnectionLost are both called, we should |
| 1119 | send an EOF message. |
1119 | 1120 | """ |
1120 | | self.pp.inConnectionLost() |
| 1121 | self.pp.outConnectionLost() |
| 1122 | self.assertFalse(self.session in self.session.conn.eofs) |
| 1123 | self.pp.errConnectionLost() |
| 1124 | self.assertTrue(self.session.conn.eofs[self.session]) |
| 1125 | |
| 1126 | |
| 1127 | def test_errConnectionLost(self): |
| 1128 | """ |
| 1129 | Make sure reverse ordering of events in test_outConnectionLost also |
| 1130 | sends EOF. |
| 1131 | """ |
| 1132 | self.pp.errConnectionLost() |
| 1133 | self.assertFalse(self.session in self.session.conn.eofs) |
| 1134 | self.pp.outConnectionLost() |
1121 | 1135 | self.assertTrue(self.session.conn.eofs[self.session]) |
1122 | 1136 | |
1123 | 1137 | |