[CalendarServer-changes] [1475] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Apr 11 14:36:28 PDT 2007
Revision: 1475
http://trac.macosforge.org/projects/calendarserver/changeset/1475
Author: dreid at apple.com
Date: 2007-04-11 14:36:28 -0700 (Wed, 11 Apr 2007)
Log Message:
-----------
Ad an UnknownPortError on the server, and on the client trap it and log it.
Also tag the request so we don't end up asking pydirector for the resolved remoteAddr multiple times. (such as with request.locateResource())
Modified Paths:
--------------
CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdamp.patch
CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdmain.patch
CalendarServer/trunk/twistedcaldav/pdmonster.py
Modified: CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdamp.patch
===================================================================
--- CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdamp.patch 2007-04-11 18:29:16 UTC (rev 1474)
+++ CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdamp.patch 2007-04-11 21:36:28 UTC (rev 1475)
@@ -1,9 +1,12 @@
--- pydirector/pdamp.py 1969-12-31 16:00:00.000000000 -0800
+++ pydirector/pdamp.py 2007-04-10 17:25:22.000000000 -0700
-@@ -0,0 +1,26 @@
+@@ -0,0 +1,34 @@
+from twisted.internet import protocol
+from twisted.protocols import amp
+
++class UnknownPortError(Exception):
++ pass
++
+class GetClientAddress(amp.Command):
+ arguments = [('host', amp.String()),
+ ('port', amp.Integer())]
@@ -11,13 +14,18 @@
+ response = [('host', amp.String()),
+ ('port', amp.Integer())]
+
++ errors = {UnknownPortError: 'UNKNOWN_PORT'}
+
++
+class PDControlProtocol(amp.AMP):
+ def __init__(self, director):
+ self.director = director
+
+ def getClientAddress(self, host, port):
+ host, port = self.director.getClientAddress(host, port)
++ if (host, port) == (None, None):
++ raise UnknownPortError()
++
+ return {'host': host, 'port': port}
+ GetClientAddress.responder(getClientAddress)
+
Modified: CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdmain.patch
===================================================================
--- CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdmain.patch 2007-04-11 18:29:16 UTC (rev 1474)
+++ CalendarServer/trunk/lib-patches/PyDirector/pydirector.pdmain.patch 2007-04-11 21:36:28 UTC (rev 1475)
@@ -21,7 +21,7 @@
+ pdamp.PDControlFactory(self))
+
+ def getClientAddress(self, host, port):
-+ return self._connections[(host, port)]
++ return self._connections.get((host, port), (None, None))
+
+ def setClientAddress(self, host, peer):
+ self._connections[host] = peer
Modified: CalendarServer/trunk/twistedcaldav/pdmonster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/pdmonster.py 2007-04-11 18:29:16 UTC (rev 1474)
+++ CalendarServer/trunk/twistedcaldav/pdmonster.py 2007-04-11 21:36:28 UTC (rev 1475)
@@ -22,20 +22,30 @@
return self.hook(request)
+ def _gotError(result):
+ result.trap(amp.RemoteAmpError)
+ if result.value.errorCode != 'UNKNOWN_PORT':
+ return result
+ logging.err('Unknown Port: %s' % (request.remoteAddr,))
+
def _gotAddress(result):
logging.debug('result = %r' % (result,))
request.remoteAddr = address.IPv4Address(
'TCP',
result['host'],
int(result['port']))
+ request._pdRewritten = True
if self.protocol is not None:
+ if hasattr(request, '_pdRewritten'):
+ return
+
host, port = request.remoteAddr.host, request.remoteAddr.port
logging.debug("GetClientAddress(host=%r, port=%r)" % (host, port))
d = self.protocol.callRemoteString("GetClientAddress",
host=host,
port=str(port))
- d.addCallback(_gotAddress)
+ d.addCallbacks(_gotAddress, _gotError)
return d
else:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070411/86ef3fb9/attachment.html
More information about the calendarserver-changes
mailing list