extras-buildsys/common AuthedXMLRPCServer.py, 1.3, 1.4 SSLCommon.py, 1.9, 1.10 SSLConnection.py, 1.1, 1.2
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Wed Jul 13 15:21:07 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9601/common
Modified Files:
AuthedXMLRPCServer.py SSLCommon.py SSLConnection.py
Log Message:
2005-07-13 Dan Williams <dcbw at redhat.com>
* common/AuthedXMLRPCServer.py
common/SSLCommon.py
common/SSLConnection.py
- Play better with Python 2.2
Index: AuthedXMLRPCServer.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/AuthedXMLRPCServer.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AuthedXMLRPCServer.py 10 Jul 2005 03:44:36 -0000 1.3
+++ AuthedXMLRPCServer.py 13 Jul 2005 15:21:05 -0000 1.4
@@ -84,6 +84,9 @@
if sys.version_info[:3] > (2, 2, 3):
SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
+ else:
+ self.funcs = {}
+ self.instance = None
def get_authinfo(self, request, client_address):
if self.authinfo_callback:
Index: SSLCommon.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/SSLCommon.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SSLCommon.py 6 Jul 2005 21:20:55 -0000 1.9
+++ SSLCommon.py 13 Jul 2005 15:21:05 -0000 1.10
@@ -88,30 +88,10 @@
self.server_port = port
-class PlgHTTPSResponse(httplib.HTTPResponse):
- def __init__(self, sock, debuglevel=0, strict=0, method=None):
- self.fp = socket._fileobject(sock, "rb", 0)
- self.debuglevel = debuglevel
- self.strict = strict
- self._method = method
-
- self.msg = None
-
- # from the Status-Line of the response
- self.version = httplib._UNKNOWN # HTTP-Version
- self.status = httplib._UNKNOWN # Status-Code
- self.reason = httplib._UNKNOWN # Reason-Phrase
-
- self.chunked = httplib._UNKNOWN # is "chunked" being used?
- self.chunk_left = httplib._UNKNOWN # bytes left to read in current chunk
- self.length = httplib._UNKNOWN # number of bytes left in response
- self.will_close = httplib._UNKNOWN # conn will close at end of response
-
-
class PlgHTTPSConnection(httplib.HTTPConnection):
"This class allows communication via SSL."
- response_class = PlgHTTPSResponse
+ response_class = httplib.HTTPResponse
def __init__(self, host, port=None, ssl_context=None, strict=None):
httplib.HTTPConnection.__init__(self, host, port, strict)
Index: SSLConnection.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/SSLConnection.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SSLConnection.py 6 Jul 2005 21:20:55 -0000 1.1
+++ SSLConnection.py 13 Jul 2005 15:21:05 -0000 1.2
@@ -25,6 +25,10 @@
so I'm making a proxy instead of subclassing.
"""
self.__dict__["conn"] = conn
+ self.__dict__["close_refcount"] = 0
+ self.__dict__["closed"] = False
+ def __del__(self):
+ self.__dict__["conn"].close()
def __getattr__(self,name):
return getattr(self.__dict__["conn"], name)
def __setattr__(self,name, value):
@@ -49,11 +53,21 @@
We need to use socket._fileobject Because SSL.Connection
doesn't have a 'dup'. Not exactly sure WHY this is, but
this is backed up by comments in socket.py and SSL/connection.c
+
+ Since httplib.HTTPSResponse/HTTPConnection depend on the
+ socket being duplicated when they close it, we refcount the
+ socket object and don't actually close until its count is 0.
"""
- return socket._fileobject(self, mode, bufsize)
+ self.__dict__["close_refcount"] = self.__dict__["close_refcount"] + 1
+ return PlgFileObject(self, mode, bufsize)
def close(self):
- self.shutdown()
- self.__dict__["conn"].close()
+ if self.__dict__["closed"]:
+ return
+ if self.__dict__["close_refcount"] == 0:
+ self.shutdown()
+ self.__dict__["conn"].close()
+ self.__dict__["closed"] = True
+ self.__dict__["close_refcount"] = self.__dict__["close_refcount"] - 1
def recv(self, bufsize):
ret = None
try:
@@ -62,3 +76,16 @@
pass
return ret
+class PlgFileObject(socket._fileobject):
+ def close(self):
+ """
+ socket._fileobject doesn't actually _close_ the socket,
+ which we want it to do, so we have to override.
+ """
+ try:
+ if self._sock:
+ self.flush()
+ self._sock.close()
+ finally:
+ self._sock = None
+
More information about the fedora-extras-commits
mailing list