summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Brewer <fumanchu@aminus.org>2006-12-23 19:37:35 +0000
committerRobert Brewer <fumanchu@aminus.org>2006-12-23 19:37:35 +0000
commiteefd2e66637eaa47d00e4b378341ca97595e94f3 (patch)
tree12a05d01629bac4e298ab9aa310eec6a55883005
parent23738de863a0c11594d1ca6b4d360cbaa44660ac (diff)
downloadcherrypy-git-eefd2e66637eaa47d00e4b378341ca97595e94f3.tar.gz
wsgiserver: Moved 'bind' inner func out to method so subclasses can override socket options more easily.
-rw-r--r--cherrypy/test/benchmark.py1
-rw-r--r--cherrypy/wsgiserver.py35
2 files changed, 19 insertions, 17 deletions
diff --git a/cherrypy/test/benchmark.py b/cherrypy/test/benchmark.py
index a5e8726c..f166fa58 100644
--- a/cherrypy/test/benchmark.py
+++ b/cherrypy/test/benchmark.py
@@ -84,6 +84,7 @@ cherrypy.config.update({
'server.socket_port': 8080,
'server.max_request_header_size': 0,
'server.max_request_body_size': 0,
+ 'engine.deadlock_poll_freq': 0,
# Cheat mode on ;)
'tools.log_tracebacks.on': False,
'tools.log_headers.on': False,
diff --git a/cherrypy/wsgiserver.py b/cherrypy/wsgiserver.py
index 9725c0b4..ba29f935 100644
--- a/cherrypy/wsgiserver.py
+++ b/cherrypy/wsgiserver.py
@@ -748,22 +748,6 @@ class CherryPyWSGIServer(object):
# trap those exceptions in whatever code block calls start().
self._interrupt = None
- def bind(family, type, proto=0):
- """Create (or recreate) the actual socket object."""
- self.socket = socket.socket(family, type, proto)
- self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- if self.ssl_certificate and self.ssl_private_key:
- if SSL is None:
- raise ImportError("You must install pyOpenSSL to use HTTPS.")
-
- # See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442473
- ctx = SSL.Context(SSL.SSLv23_METHOD)
- ctx.use_privatekey_file(self.ssl_private_key)
- ctx.use_certificate_file(self.ssl_certificate)
- self.socket = SSLConnection(ctx, self.socket)
- self.populate_ssl_environ()
- self.socket.bind(self.bind_addr)
-
# Select the appropriate socket
if isinstance(self.bind_addr, basestring):
# AF_UNIX socket
@@ -805,7 +789,7 @@ class CherryPyWSGIServer(object):
for res in info:
af, socktype, proto, canonname, sa = res
try:
- bind(af, socktype, proto)
+ self.bind(af, socktype, proto)
except socket.error, msg:
if self.socket:
self.socket.close()
@@ -838,6 +822,23 @@ class CherryPyWSGIServer(object):
time.sleep(0.1)
raise self.interrupt
+ def bind(self, family, type, proto=0):
+ """Create (or recreate) the actual socket object."""
+ self.socket = socket.socket(family, type, proto)
+ self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+## self.socket.setsockopt(socket.SOL_SOCKET, socket.TCP_NODELAY, 1)
+ if self.ssl_certificate and self.ssl_private_key:
+ if SSL is None:
+ raise ImportError("You must install pyOpenSSL to use HTTPS.")
+
+ # See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442473
+ ctx = SSL.Context(SSL.SSLv23_METHOD)
+ ctx.use_privatekey_file(self.ssl_private_key)
+ ctx.use_certificate_file(self.ssl_certificate)
+ self.socket = SSLConnection(ctx, self.socket)
+ self.populate_ssl_environ()
+ self.socket.bind(self.bind_addr)
+
def tick(self):
"""Accept a new connection and put it on the Queue."""
try: