[CalendarServer-changes] [2571] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue Jun 17 10:56:12 PDT 2008


Revision: 2571
          http://trac.macosforge.org/projects/calendarserver/changeset/2571
Author:   dreid at apple.com
Date:     2008-06-17 10:56:11 -0700 (Tue, 17 Jun 2008)

Log Message:
-----------
EnableKeepAlive and IdleConnectionTimeOut options.  Allow keep alives (default true) and number of seconds to wait between requests on a persistent connection, respectively.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/config.py
    CalendarServer/trunk/twistedcaldav/root.py
    CalendarServer/trunk/twistedcaldav/tap.py

Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py	2008-06-17 14:50:23 UTC (rev 2570)
+++ CalendarServer/trunk/twistedcaldav/config.py	2008-06-17 17:56:11 UTC (rev 2571)
@@ -69,7 +69,7 @@
     "DocumentRoot"         : "/Library/CalendarServer/Documents",
     "UserQuota"            : 104857600, # User quota (in bytes)
     "MaximumAttachmentSize":   1048576, # Attachment size limit (in bytes)
-    
+
     #
     # Directory service
     #
@@ -220,8 +220,12 @@
         "MaxMemory": 0, # Megabytes
         "Options": [],
     },
+
+    "EnableKeepAlive": True,
+    "IdleConnectionTimeOut": 15,
 }
 
+
 class Config (object):
     def __init__(self, defaults):
         self.setDefaults(defaults)

Modified: CalendarServer/trunk/twistedcaldav/root.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/root.py	2008-06-17 14:50:23 UTC (rev 2570)
+++ CalendarServer/trunk/twistedcaldav/root.py	2008-06-17 17:56:11 UTC (rev 2571)
@@ -34,6 +34,12 @@
 
 log = Logger()
 
+def addConnectionClose(request, response):
+    response.headers.setHeader('connection', ('close',))
+    request.chanRequest.channel.setReadPersistent(False)
+    return response
+
+
 class RootResource(DAVFile):
     """
     A special root resource that contains support checking SACLs
@@ -68,12 +74,17 @@
             from twisted.web2.filter import gzip
             self.contentFilters.append((gzip.gzipfilter, True))
 
+        if not config.EnableKeepAlive:
+            self.contentFilters.append((addConnectionClose, True))
+
+
     def deadProperties(self):
         if not hasattr(self, '_dead_properties'):
             self._dead_properties = CachingXattrPropertyStore(self)
 
         return self._dead_properties
 
+
     def checkSacl(self, request):
         """
         Check SACLs against the current request

Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py	2008-06-17 14:50:23 UTC (rev 2570)
+++ CalendarServer/trunk/twistedcaldav/tap.py	2008-06-17 17:56:11 UTC (rev 2571)
@@ -670,7 +670,10 @@
 
         site = Site(realRoot)
 
-        channel = http.HTTPFactory(site, maxRequests=config.MaxRequests)
+        channel = http.HTTPFactory(
+            site,
+            maxRequests=config.MaxRequests,
+            betweenRequestsTimeOut=config.IdleConnectionTimeOut)
 
         if not config.BindAddresses:
             config.BindAddresses = [""]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080617/f31f4737/attachment.htm 


More information about the calendarserver-changes mailing list