]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Locking failures on windows are indicated by EACCES
authorSebastian Hahn <sebastian@torproject.org>
Mon, 7 Feb 2011 14:40:14 +0000 (15:40 +0100)
committerSebastian Hahn <sebastian@torproject.org>
Tue, 8 Feb 2011 17:35:07 +0000 (18:35 +0100)
Patch our implementation of tor_lockfile_lock() to handle this case
correctly. Also add a note that blocking behaviour differs from windows
to *nix. Fixes bug 2504, issue pointed out by mobmix.

src/common/compat.c

index aa42514ddf5d56926dc9e815d252fd12138a2bae..5dfde3dc03737cbe7de96996f2bd8e00e0ec943f 100644 (file)
@@ -676,7 +676,10 @@ struct tor_lockfile_t {
  *
  * (Implementation note: because we need to fall back to fcntl on some
  *  platforms, these locks are per-process, not per-thread.  If you want
- *  to do in-process locking, use tor_mutex_t like a normal person.)
+ *  to do in-process locking, use tor_mutex_t like a normal person.
+ *  On Windows, when <b>blocking</b> is true, the maximum time that
+ *  is actually waited is 10 seconds, after which NULL is returned
+ *  and <b>locked_out</b> is set to 1.)
  */
 tor_lockfile_t *
 tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
@@ -696,7 +699,7 @@ tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
 #ifdef WIN32
   _lseek(fd, 0, SEEK_SET);
   if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLCK, 1) < 0) {
-    if (errno != EDEADLOCK)
+    if (errno != EACCESS && errno != EDEADLOCK)
       log_warn(LD_FS,"Couldn't lock \"%s\": %s", filename, strerror(errno));
     else
       *locked_out = 1;