[CalendarServer-changes] [6517] CalendarServer/branches/users/glyph/sharedpool

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 1 14:19:58 PDT 2010


Revision: 6517
          http://trac.macosforge.org/projects/calendarserver/changeset/6517
Author:   glyph at apple.com
Date:     2010-11-01 14:19:55 -0700 (Mon, 01 Nov 2010)
Log Message:
-----------
some slight refactorings; add DBAMPFD but don't use it yet

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py
    CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/mail.py
    CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/stdconfig.py

Modified: CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py	2010-11-01 21:19:30 UTC (rev 6516)
+++ CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py	2010-11-01 21:19:55 UTC (rev 6517)
@@ -679,16 +679,22 @@
         return service
 
 
+    def scheduleOnDiskUpgrade(self):
+        """
+        Schedule any on disk upgrades we might need.  Note that this will only
+        do the filesystem-format upgrades; migration to the database needs to
+        be done when the connection and possibly server is already up and
+        running.
+        """
+        addSystemEventTrigger("before", "startup", upgradeData, config)
+
+
     def makeService_Single(self, options):
         """
         Create a service to be used in a single-process, stand-alone
         configuration.
         """
-        # Schedule any on disk upgrades we might need.  Note that this
-        # will only do the filesystem-format upgrades; migration to the
-        # database needs to be done when the connection and possibly
-        # server is already up and running. -glyph
-        addSystemEventTrigger("before", "startup", upgradeData, config)
+        self.scheduleOnDiskUpgrade()
 
         return self.storageService(self.makeService_Slave(options))
 
@@ -733,7 +739,9 @@
                     # FIXME: somehow, this should be a connection pool too, not
                     # unpooled connections; this only runs in the master
                     # process, so this would be a good point to bootstrap that
-                    # whole process.
+                    # whole process.  However, it's somewhat tricky to do that
+                    # right.  The upgrade needs to run in the master, before
+                    # any other things have run.
                     pgserv.produceLocalTransaction, attachmentsRoot,
                     uid=postgresUID, gid=postgresGID
                 )
@@ -766,11 +774,7 @@
         """
         s = ErrorLoggingMultiService()
 
-        # Schedule any on disk upgrades we might need.  Note that this
-        # will only do the filesystem-format upgrades; migration to the
-        # database needs to be done when the connection and possibly
-        # server is already up and running. -glyph
-        addSystemEventTrigger("before", "startup", upgradeData, config)
+        self.scheduleOnDiskUpgrade()
 
         # Make sure no old socket files are lying around.
         self.deleteStaleSocketFiles()
@@ -1066,11 +1070,17 @@
         subprocess and used to accept incoming connections.
 
     @type metaSocket: L{socket.socket}
+
+    @ivar ampDBSocket: an AF_UNIX/SOCK_STREAM socket that is to be inherited by
+        subprocesses and used for sending AMP SQL commands back to its parent.
+
+    @type ampDBSocket: L{socket.socket}
     """
     prefix = "caldav"
 
     def __init__(self, twistd, tapname, configFile, id, interfaces,
-                 inheritFDs=None, inheritSSLFDs=None, metaSocket=None):
+                 inheritFDs=None, inheritSSLFDs=None, metaSocket=None,
+                 ampDBSocket=None):
 
         self.twistd = twistd
 
@@ -1088,6 +1098,7 @@
         self.inheritSSLFDs = emptyIfNone(inheritSSLFDs)
         self.metaSocket = metaSocket
         self.interfaces = interfaces
+        self.ampDBSocket = ampDBSocket
 
     def getName(self):
         return '%s-%s' % (self.prefix, self.id)
@@ -1099,10 +1110,11 @@
             process to file descriptor numbers in the current (master) process.
         """
         fds = {}
-        maybeMetaFD = []
-        if self.metaSocket is not None:
-            maybeMetaFD.append(self.metaSocket.fileno())
-        for fd in self.inheritSSLFDs + self.inheritFDs + maybeMetaFD:
+        extraFDs = []
+        for it in [self.metaSocket, self.ampDBSocket]:
+            if it is not None:
+                extraFDs.append(it.fileno())
+        for fd in self.inheritSSLFDs + self.inheritFDs + extraFDs:
             fds[fd] = fd
         return fds
 
@@ -1155,11 +1167,15 @@
                 "-o", "InheritSSLFDs=%s" % (",".join(map(str, self.inheritSSLFDs)),)
             ])
 
+
         if self.metaSocket is not None:
             args.extend([
                     "-o", "MetaFD=%s" % (self.metaSocket.fileno(),)
                 ])
-
+        if self.ampDBSocket is not None:
+            args.extend([
+                    "-o", "DBAMPFD=%s" % (self.ampDBSocket.fileno(),)
+                ])
         return args
 
 

Modified: CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/mail.py	2010-11-01 21:19:30 UTC (rev 6516)
+++ CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/mail.py	2010-11-01 21:19:55 UTC (rev 6517)
@@ -587,10 +587,10 @@
         return multiService
 
 
-#
-# ISchedule Inbox
-#
 class IScheduleService(service.MultiService, LoggingMixIn):
+    """
+    ISchedule Inbox
+    """
 
     def __init__(self, settings, mailer):
         self.settings = settings
@@ -611,8 +611,6 @@
 
 
 
-
-
 class MailHandler(LoggingMixIn):
 
     def __init__(self, dataRoot=None):

Modified: CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/stdconfig.py	2010-11-01 21:19:30 UTC (rev 6516)
+++ CalendarServer/branches/users/glyph/sharedpool/twistedcaldav/stdconfig.py	2010-11-01 21:19:55 UTC (rev 6517)
@@ -139,17 +139,27 @@
     #    This configures the actual network address that the server binds to.
     #
     "BindAddresses": [],   # List of IP addresses to bind to [empty = all]
-    "BindHTTPPorts": [],   # List of port numbers to bind to for HTTP [empty = same as "Port"]
-    "BindSSLPorts" : [],   # List of port numbers to bind to for SSL [empty = same as "SSLPort"]
-    "InheritFDs"   : [],   # File descriptors to inherit for HTTP requests (empty = don't inherit)
-    "InheritSSLFDs": [],   # File descriptors to inherit for HTTPS requests (empty = don't inherit)
-    "MetaFD": 0,        # Inherited file descriptor to call recvmsg() on to receive sockets (none = don't inherit)
+    "BindHTTPPorts": [],   # List of port numbers to bind to for HTTP
+                           # [empty = same as "Port"]
+    "BindSSLPorts" : [],   # List of port numbers to bind to for SSL
+                           # [empty = same as "SSLPort"]
+    "InheritFDs"   : [],   # File descriptors to inherit for HTTP requests
+                           # (empty = don't inherit)
+    "InheritSSLFDs": [],   # File descriptors to inherit for HTTPS requests
+                           # (empty = don't inherit)
+    "MetaFD"       : 0,    # Inherited file descriptor to call recvmsg() on to
+                           # receive sockets (none = don't inherit)
 
-    "UseMetaFD": True,         # Use a 'meta' FD, i.e. an FD to transmit other
-                               # FDs to slave processes.
+    "UseMetaFD"    : True, # Use a 'meta' FD, i.e. an FD to transmit other FDs
+                           # to slave processes.
 
-    "UseDatabase" : True,      # True: postgres; False: files
+    "UseDatabase"  : True, # True: postgres; False: files
 
+    "DBAMPFD"      : 0,    # Internally used by database to tell slave
+                           # processes to inherit a file descriptor and use it
+                           # as an AMP connection over a UNIX socket; see
+                           # txdav.base.datastore.asyncsqlpool.
+
     #
     # Types of service provided
     #
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101101/96f2e9cf/attachment.html>


More information about the calendarserver-changes mailing list