extras-buildsys/common SSLCommon.py, 1.5, 1.6 SimpleHTTPSServer.py, 1.4, 1.5 SimpleSSLXMLRPCServer.py, 1.6, 1.7
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Mon Jun 27 02:40:56 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22004/common
Modified Files:
SSLCommon.py SimpleHTTPSServer.py SimpleSSLXMLRPCServer.py
Log Message:
2005-06-26 Dan Williams <dcbw at redhat.com>
* client/buildclient.py
common/SSLCommon.py
common/SimpleHTTPSServer.py
common/SimpleSSLXMLRPCServer.py
- Set a much lower socket read timeout than the default, which
is 600 seconds. We don't want clients blocking the server
for too long, and non-blocking sockets are a bit too
complicated at this time.
Index: SSLCommon.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/SSLCommon.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SSLCommon.py 19 Jun 2005 02:47:53 -0000 1.5
+++ SSLCommon.py 27 Jun 2005 02:40:54 -0000 1.6
@@ -50,12 +50,22 @@
return ctx
-class QuietSSLServer(SSL.SSLServer):
+class QuietSSLServer(SSL.ThreadingSSLServer):
+ def __init__(self, server_address, RequestHandlerClass, ssl_context):
+ SSL.SSLServer.__init__(self, server_address, RequestHandlerClass, ssl_context)
+
+ # About the last thing we want is a client blocking the server
+ # because it hung or tracebacked
+ timeout = SSL.timeout(10)
+ self.socket.set_socket_read_timeout(timeout)
+
def handle_request(self):
request = None
client_address = None
try:
request, client_address = self.get_request()
+ timeout = SSL.timeout(10)
+ request.set_socket_read_timeout(timeout)
if self.verify_request(request, client_address):
self.process_request(request, client_address)
except SSL.SSLError, e:
Index: SimpleHTTPSServer.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/SimpleHTTPSServer.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SimpleHTTPSServer.py 14 Jun 2005 01:16:30 -0000 1.4
+++ SimpleHTTPSServer.py 27 Jun 2005 02:40:54 -0000 1.5
@@ -27,6 +27,9 @@
from M2Crypto import Rand, SSL
from M2Crypto.SSL.SSLServer import ThreadingSSLServer
import SSLCommon
+import socket
+import time
+
class HttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@@ -83,11 +86,31 @@
self.server_name = server_addr[0]
self.server_port = server_addr[1]
+ # About the last thing we want is a client blocking the server
+ # because it hung or tracebacked
+ timeout = SSL.timeout(10)
+ self.socket.set_socket_read_timeout(timeout)
+
def finish(self):
if self.request:
self.request.set_shutdown(SSL.SSL_RECEIVED_SHUTDOWN | SSL.SSL_SENT_SHUTDOWN)
self.request.close()
+ def serve_forever(self):
+ while True:
+ try:
+ self.handle_request()
+ except KeyboardInterrupt, e:
+ print "Shutting down..."
+ break
+ except socket.error, e:
+ if e[0] == 11: # Resource temporarily unavailable
+ try:
+ time.sleep(0.1)
+ except KeyboardInterrupt, e:
+ print "Shutting down..."
+ break
+
class SimpleHTTPSServer(threading.Thread):
Index: SimpleSSLXMLRPCServer.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/common/SimpleSSLXMLRPCServer.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SimpleSSLXMLRPCServer.py 24 Jun 2005 10:47:40 -0000 1.6
+++ SimpleSSLXMLRPCServer.py 27 Jun 2005 02:40:54 -0000 1.7
@@ -16,6 +16,8 @@
# Modified by Dan Williams <dcbw at redhat.com>
import os, sys
+import socket
+import time
from M2Crypto import SSL
import xmlrpclib
import SimpleXMLRPCServer
@@ -162,3 +164,17 @@
return SimpleXMLRPCServer.resolve_dotted_attribute(
self.instance, method, self.allow_dotted_names)
+ def serve_forever(self):
+ while True:
+ try:
+ self.handle_request()
+ except KeyboardInterrupt, e:
+ print "Shutting down..."
+ break
+ except socket.error, e:
+ if e[0] == 11: #Resource temporarily unavailable
+ try:
+ time.sleep(0.1)
+ except KeyboardInterrupt, e:
+ print "Shutting down..."
+ break
More information about the fedora-extras-commits
mailing list