[CalendarServer-changes] [6596] CalendarServer/branches/users/glyph/dont-start-postgres/ calendarserver/tap/caldav.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 10 18:53:33 PST 2010
Revision: 6596
http://trac.macosforge.org/projects/calendarserver/changeset/6596
Author: glyph at apple.com
Date: 2010-11-10 18:53:30 -0800 (Wed, 10 Nov 2010)
Log Message:
-----------
More config refactoring. Only examine RedirectHTTPToHTTPS once, only log about it once, and put the logic for the default to BindAddresses in a central place.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py
Modified: CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py 2010-11-11 02:53:07 UTC (rev 6595)
+++ CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py 2010-11-11 02:53:30 UTC (rev 6596)
@@ -548,6 +548,7 @@
requestFactory = underlyingSite
if config.RedirectHTTPToHTTPS:
+ self.log_info("Redirecting to HTTPS port %s" % (config.SSLPort,))
def requestFactory(*args, **kw):
return SSLRedirectRequest(site=underlyingSite, *args, **kw)
@@ -569,29 +570,21 @@
# Inherit sockets to call accept() on them individually.
if config.EnableSSL:
- for fd in config.InheritSSLFDs:
- fd = int(fd)
-
+ for fdAsStr in config.InheritSSLFDs:
try:
contextFactory = self.createContextFactory()
except SSLError, e:
log.error("Unable to set up SSL context factory: %s" % (e,))
else:
MaxAcceptSSLServer(
- fd, httpFactory,
+ int(fdAsStr), httpFactory,
contextFactory,
backlog=config.ListenBacklog,
inherit=True
).setServiceParent(service)
-
- for fd in config.InheritFDs:
- fd = int(fd)
-
- if config.RedirectHTTPToHTTPS:
- self.log_info("Redirecting to HTTPS port %s" % (config.SSLPort,))
-
+ for fdAsStr in config.InheritFDs:
MaxAcceptTCPServer(
- fd, httpFactory,
+ int(fdAsStr), httpFactory,
backlog=config.ListenBacklog,
inherit=True
).setServiceParent(service)
@@ -600,8 +593,6 @@
# Inherit a single socket to receive accept()ed connections via
# recvmsg() and SCM_RIGHTS.
- fd = int(config.MetaFD)
-
try:
contextFactory = self.createContextFactory()
except SSLError, e:
@@ -612,15 +603,11 @@
contextFactory = None
ReportingHTTPService(
- requestFactory, fd, contextFactory
+ requestFactory, int(config.MetaFD), contextFactory
).setServiceParent(service)
else: # Not inheriting, therefore we open our own:
-
- if not config.BindAddresses:
- config.BindAddresses = [""]
-
- for bindAddress in config.BindAddresses:
+ for bindAddress in self._allBindAddresses():
self._validatePortConfig()
if config.EnableSSL:
for port in config.BindSSLPorts:
@@ -643,20 +630,6 @@
httpsService.setServiceParent(service)
for port in config.BindHTTPPorts:
-
- if config.RedirectHTTPToHTTPS:
- #
- # Redirect non-SSL ports to the configured SSL port.
- #
- self.log_info("Redirecting HTTP port %s to HTTPS port %s"
- % (port, config.SSLPort)
- )
- else:
- self.log_info(
- "Adding server at %s:%s"
- % (bindAddress, port)
- )
-
MaxAcceptTCPServer(
int(port), httpFactory,
interface=bindAddress,
@@ -697,6 +670,17 @@
config.BindSSLPorts = [config.SSLPort]
+ def _allBindAddresses(self):
+ """
+ An empty array for the config value of BindAddresses should be
+ equivalent a BindAddresses with a single empty string, meaning "bind
+ everything".
+ """
+ if not config.BindAddresses:
+ config.BindAddresses = [""]
+ return config.BindAddresses
+
+
def scheduleOnDiskUpgrade(self):
"""
Schedule any on disk upgrades we might need. Note that this will only
@@ -862,9 +846,6 @@
# Open the socket(s) to be inherited by the slaves
- if not config.BindAddresses:
- config.BindAddresses = [""]
-
inheritFDs = []
inheritSSLFDs = []
@@ -876,7 +857,7 @@
else:
s._inheritedSockets = [] # keep a reference to these so they don't close
- for bindAddress in config.BindAddresses:
+ for bindAddress in self._allBindAddresses():
self._validatePortConfig()
if config.UseMetaFD:
portsList = [(config.BindHTTPPorts, "TCP")]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101110/05fd8acd/attachment-0001.html>
More information about the calendarserver-changes
mailing list