Revision
3586
Author
sagen@apple.com
Date
2009-01-12 11:51:36 -0800 (Mon, 12 Jan 2009)

Log Message

Race condition fix: a DELETE can remove a resource after the calendar-multiget code has already determined that resource exists.  In this case, we now return a 404 response for that resource within the multistatus.

Modified Paths

Diff

Modified: CalendarServer/trunk/twistedcaldav/method/report_multiget.py (3585 => 3586)


--- CalendarServer/trunk/twistedcaldav/method/report_multiget.py	2009-01-12 15:37:38 UTC (rev 3585)
+++ CalendarServer/trunk/twistedcaldav/method/report_multiget.py	2009-01-12 19:51:36 UTC (rev 3586)
@@ -172,6 +172,14 @@
                 except ValueError:
                     log.err("Invalid calendar resource during multiget: %s" % (href,))
                     responses.append(davxml.StatusResponse(davxml.HRef.fromString(href), davxml.Status.fromResponseCode(responsecode.FORBIDDEN)))
+                except IOError:
+                    # This can happen because of a race-condition between the
+                    # time we determine which resources exist and the deletion
+                    # of one of these resources in another request.  In this
+                    # case, return a 404 for the now missing resource rather
+                    # than raise an error for the entire report.
+                    log.err("Missing calendar resource during multiget: %s" % (href,))
+                    responses.append(davxml.StatusResponse(davxml.HRef.fromString(href), davxml.Status.fromResponseCode(responsecode.NOT_FOUND)))
 
             # Indicate error for all valid non-readable resources
             for ignore_resource, href in bad_resources: