[CalendarServer-changes] [9060] CalendarServer/branches/users/glyph/ipv6-client/twext/internet
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 13 11:44:13 PDT 2012
Revision: 9060
http://trac.macosforge.org/projects/calendarserver/changeset/9060
Author: glyph at apple.com
Date: 2012-04-13 11:44:13 -0700 (Fri, 13 Apr 2012)
Log Message:
-----------
disconnect while connected
Modified Paths:
--------------
CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py
CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py
Modified: CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py
===================================================================
--- CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py 2012-04-13 18:44:08 UTC (rev 9059)
+++ CalendarServer/branches/users/glyph/ipv6-client/twext/internet/adaptendpoint.py 2012-04-13 18:44:13 UTC (rev 9060)
@@ -110,7 +110,10 @@
def attemptDone(result):
self._outstandingAttempt = None
return result
- d.addErrback(self.callClientConnectionFailed)
+ def rememberProto(proto):
+ self._connectedProtocol = proto
+ return proto
+ d.addCallbacks(rememberProto, self.callClientConnectionFailed)
def callStartedConnecting(self):
Modified: CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py
===================================================================
--- CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py 2012-04-13 18:44:08 UTC (rev 9059)
+++ CalendarServer/branches/users/glyph/ipv6-client/twext/internet/test/test_adaptendpoint.py 2012-04-13 18:44:13 UTC (rev 9060)
@@ -175,4 +175,26 @@
self.assertTrue(rcf.fails[0].reason.check(CancelledError))
+ def test_disconnectWhileConnected(self):
+ """
+ If the L{IConnector} is told to C{disconnect} while an existing
+ connection is established, that connection will be dropped via
+ C{loseConnection}.
+ """
+ rcf = RecordingClientFactory()
+ e = RecordingEndpoint()
+ connect(e, rcf)
+ d = e.attempts[0].deferred
+ lose = []
+ class Transport(object):
+ def loseConnection(self):
+ lose.append(self)
+ proto = e.attempts[0].factory.buildProtocol(object())
+ tpt = Transport()
+ proto.makeConnection(tpt)
+ d.callback(proto)
+ rcf.starts[0].disconnect()
+ self.assertEqual(lose, [tpt])
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120413/45c945c0/attachment-0001.html>
More information about the calendarserver-changes
mailing list