[CalendarServer-changes] [4922] CalendarServer/trunk/twistedcaldav/scheduling/processing.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 13 18:23:05 PST 2010


Revision: 4922
          http://trac.macosforge.org/projects/calendarserver/changeset/4922
Author:   cdaboo at apple.com
Date:     2010-01-13 18:23:01 -0800 (Wed, 13 Jan 2010)
Log Message:
-----------
Need some extra locking when doing implicit auto-replies.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/scheduling/processing.py

Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2010-01-13 21:11:04 UTC (rev 4921)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py	2010-01-14 02:23:01 UTC (rev 4922)
@@ -30,6 +30,7 @@
 from twistedcaldav.scheduling.itip import iTipProcessing, iTIPRequestStatus
 from twistedcaldav.scheduling.utils import getCalendarObjectForPrincipals
 from vobject.icalendar import utc
+from twistedcaldav.memcachelock import MemcacheLock, MemcacheLockTimeoutError
 import datetime
 import time
 
@@ -410,6 +411,7 @@
 
         returnValue(result)
 
+    @inlineCallbacks
     def sendAttendeeAutoReply(self, calendar, resource, partstat):
         """
         Auto-process the calendar option to generate automatic accept/decline status and
@@ -421,12 +423,29 @@
         @return: L{Component} for the new calendar data to write
         """
         
-        # Send out a reply
-        log.debug("ImplicitProcessing - recipient '%s' processing UID: '%s' - auto-reply: %s" % (self.recipient.cuaddr, self.uid, partstat))
-        from twistedcaldav.scheduling.implicit import ImplicitScheduler
-        scheduler = ImplicitScheduler()
-        scheduler.sendAttendeeReply(self.request, resource, calendar, self.recipient)
+        # We need to get the UID lock for implicit processing whilst we send the auto-reply
+        # as the Organizer processing will attempt to write out data to other attendees to
+        # refresh them. To prevent a race we need a lock.
+        lock = MemcacheLock("ImplicitUIDLock", calendar.resourceUID(), timeout=60.0)
 
+        try:
+            if lock:
+                yield lock.acquire()
+
+            # Send out a reply
+            log.debug("ImplicitProcessing - recipient '%s' processing UID: '%s' - auto-reply: %s" % (self.recipient.cuaddr, self.uid, partstat))
+            from twistedcaldav.scheduling.implicit import ImplicitScheduler
+            scheduler = ImplicitScheduler()
+            scheduler.sendAttendeeReply(self.request, resource, calendar, self.recipient)
+        except MemcacheLockTimeoutError:
+            
+            # Just try again to get the lock
+            reactor.callLater(2.0, self.sendAttendeeAutoReply, *(calendar, resource, partstat))
+    
+        finally:
+            if lock:
+                yield lock.clean()
+
     @inlineCallbacks
     def checkAttendeeAutoReply(self, calendar):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100113/d05afc3d/attachment.html>


More information about the calendarserver-changes mailing list