Comment 4 for bug 143422

Revision history for this message
alzhimer (alzhimer) wrote :

okay, I shouldn't trust my feelings too much. I compared some startup times with and without the late binding change, and must admit that they look very similar. However, I believe that the late binding is a good thing for our load balanced setup - I don't want users to get blank pages only because zope opens a port while still not ready to handle it. Here is a improved patch which does the late binding only if there is no port <= 1024 configured:

Index: __init__.py
===================================================================
--- __init__.py (revision 30421)
+++ __init__.py (working copy)
@@ -86,10 +86,14 @@
         self.setupLocale()
         self.setupSecurityOptions()
         self.setupPublisher()
- # Start ZServer servers before we drop privileges so we can bind to
- # "low" ports:
         self.setupZServer()
- self.setupServers()
+ self.setBindEarly()
+
+ if self.bind_early:
+ # Start ZServer servers before we drop privileges so we can bind to
+ # "low" ports:
+ self.setupServers()
+
         # drop privileges after setting up servers
         self.dropPrivileges()
         self.makeLockFile()
@@ -100,6 +104,10 @@
         # emit a "ready" message in order to prevent the kinds of emails
         # to the Zope maillist in which people claim that Zope has "frozen"
         # after it has emitted ZServer messages.
+
+ if not self.bind_early:
+ self.setupServers()
+
         logger.info('Ready to handle requests')
         self.setupFinalLogging()

@@ -208,6 +216,13 @@
                                                  % (server.servertype(),e[1]))
         self.cfg.servers = servers

+ def setBindEarly(self):
+ self.bind_early = False
+ for server in self.cfg.servers:
+ if server.port <= 1024:
+ self.bind_early = True
+ return self.bind_early
+
     def dropPrivileges(self):
         return dropPrivileges(self.cfg)

Cheers, Sascha