[CalendarServer-changes] [6519] CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/ util.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 1 14:20:42 PDT 2010


Revision: 6519
          http://trac.macosforge.org/projects/calendarserver/changeset/6519
Author:   glyph at apple.com
Date:     2010-11-01 14:20:40 -0700 (Mon, 01 Nov 2010)
Log Message:
-----------
sketch of amp-sql-fd support

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py

Modified: CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py	2010-11-01 21:20:18 UTC (rev 6518)
+++ CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py	2010-11-01 21:20:40 UTC (rev 6519)
@@ -22,6 +22,7 @@
 import errno
 import os
 from time import sleep
+from socket import fromfd
 
 from twext.python.filepath import CachingFilePath as FilePath
 from twext.python.log import Logger
@@ -34,6 +35,7 @@
 from twisted.cred.portal import Portal
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.internet.reactor import addSystemEventTrigger
+from twisted.internet.tcp import Connection
 from twisted.python.reflect import namedClass
 
 from twistedcaldav import memcachepool
@@ -62,6 +64,7 @@
 except ImportError:
     NegotiateCredentialFactory = None
 from txdav.base.datastore.asyncsqlpool import ConnectionPool
+from txdav.base.datastore.asyncsqlpool import ConnectionPoolClient
 
 from calendarserver.accesslog import DirectoryLogWrapperResource
 from calendarserver.provision.root import RootResource
@@ -105,11 +108,21 @@
     """
     if config.UseDatabase:
         postgresService = pgServiceFromConfig(config, None)
-        cp = ConnectionPool(postgresService.produceConnection)
-        cp.setServiceParent(serviceParent)
-
+        if config.DBAMPFD == 0:
+            cp = ConnectionPool(postgresService.produceConnection)
+            cp.setServiceParent(serviceParent)
+            txnFactory = cp.connection
+        else:
+            # TODO: something to do with loseConnection here, maybe?  I don't
+            # think it actually needs to be shut down, though.
+            skt = fromfd(config.DBAMPFD)
+            protocol = ConnectionPoolClient()
+            transport = Connection(skt, protocol) # XXX may need subclass for
+                                                  # getPeer and getHost
+            protocol.makeConnection(transport)
+            txnFactory = protocol.newTransaction
         dataStore = CommonSQLDataStore(
-            cp.connection, notifierFactory,
+            txnFactory, notifierFactory,
             postgresService.dataStoreDirectory.child("attachments"),
             config.EnableCalDAV, config.EnableCardDAV
         )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101101/d42af50d/attachment.html>


More information about the calendarserver-changes mailing list