]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use the FILE_SHARE_DELETE flag for CreateFile on a mapping
authorNick Mathewson <nickm@torproject.org>
Wed, 12 Jun 2013 13:53:46 +0000 (09:53 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 12 Jun 2013 13:53:46 +0000 (09:53 -0400)
A comment by rransom on #8795 taken together with a comment by doorss
recorded on #2077 suggest that *every* attempt to replace the md cache
will fail on Vista/Win7 if we don't have the FILE_SHARE_DELETE flag
passed to CreateFile, and if we try to replace the file ourselves
before unmapping it.  I'm adding the FILE_SHARE_DELETE, since that's
this simplest fix.  Broken indexers (the favored #2077 hypothesis)
could still cause trouble here, but at least this patch should make us
stop stepping on our own feet.

Likely fix for #2077 and its numerous duplicates. Bugfix on
0.2.2.6-alpha, which first had a microdescriptor cache that would get
replaced before remapping it.

changes/bug2077_share_delete [new file with mode: 0644]
src/common/compat.c

diff --git a/changes/bug2077_share_delete b/changes/bug2077_share_delete
new file mode 100644 (file)
index 0000000..71e9160
--- /dev/null
@@ -0,0 +1,7 @@
+  o Major bugfixes (windows):
+    - Open files to be mapped with FILE_SHARE_DELETE so that we can
+      replace them before closing the mapping. This is a likely cause of
+      warnings and crashes when replacing the microdescriptor cache
+      file. Diagnosed based on comments by "doorss" and by Robert
+      Ransom. Possible fix for bug 2077; bugfix on 0.2.2.6-alpha.
+
index 59e3898debd6e14d808f6ccb609a11f934f2b358..7f7405f6fd23038818c47cf16b67db7fc5332239 100644 (file)
@@ -238,7 +238,7 @@ tor_mmap_file(const char *filename)
   strlcpy(tfilename,filename,MAX_PATH);
 #endif
   file_handle = CreateFile(tfilename,
-                           GENERIC_READ, FILE_SHARE_READ,
+                           GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_DELETE,
                            NULL,
                            OPEN_EXISTING,
                            FILE_ATTRIBUTE_NORMAL,