httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 47657] New: Make WebDAV MOVE atomic when replacing files on same device
Date Thu, 06 Aug 2009 21:55:36 GMT

           Summary: Make WebDAV MOVE atomic when replacing files on same
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_dav

--- Comment #0 from 2009-08-06 14:55:34 PDT ---
When WebDAV MOVE is used to replace an existing file with a new one, mod_dav
systematically deletes the destination file before moving the new file to the
destination filename. This non-atomicity leads to a race condition whereby GET
requests can return 404 Not Found for a short time. When the source and
destination are on the same filesystem, it should be possible to use standard
OS APIs for file renaming (which generally support atomic file replacement)
without deleting the destination file first.

See line 2873 of modules/dav/main/mod_dav.c

    /* If destination is being replaced, remove it first
     * (we know Ovewrite must be TRUE). Then try to copy/move the resource.
    if (replace_dest)
        err = (*resnew->hooks->remove_resource)(resnew, &multi_response);

    if (err == NULL) {
        if (is_move)
            err = (*resource->hooks->move_resource)(resource, resnew,
            err = (*resource->hooks->copy_resource)(resource, resnew, depth,

It may be sufficient to simply suppress the call to remove_resource to fix this
bug, although I haven't tried it...

The original WebDAV specification (RFC 2518) clearly says that the replacement
should occur atomically:

8.9 MOVE Method

   The MOVE operation on a non-collection resource is the logical
   equivalent of a copy (COPY), followed by consistency maintenance
   processing, followed by a delete of the source, where all three
   actions are performed atomically.

The more recent specification (RFC 4918) changes the wording slightly: "all
three actions are performed in a single operation". Whether this means "atomic"
is debatable. Nevertheless, it is highly useful in practice for the operation
to be atomic whenever possible.

Note: To ensure atomic file replacement on Win32, it is apparently necessary to
use MoveFileTransacted to ensure atomicity (see, although
this API is only supported on Vista and later. For other OSes, POSIX rename
should do the job.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message