diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2011-02-07 15:40:14 +0100 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2011-02-08 18:35:07 +0100 |
commit | 9c7e2cf010856aabfbca042870ec1d5718c30ea4 (patch) | |
tree | 3dd51067fe26a7738928c50014dbe5a9d662c059 /src/common | |
parent | 54ccc80a4a740c175f279d00dc5441c673b0263c (diff) | |
download | tor-9c7e2cf010856aabfbca042870ec1d5718c30ea4.tar.gz tor-9c7e2cf010856aabfbca042870ec1d5718c30ea4.zip |
Locking failures on windows are indicated by EACCES
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.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index aa42514ddf..5dfde3dc03 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -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; |