From a95e0e73559349fbbcd97c183ffd481616cbfd5e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 11 Nov 2008 15:29:40 +0000 Subject: [PATCH] apply sebastian's fix for bug 859. Apparently on win32 one must lock at least one byte when locking, but locking a nonexistant byte is okay. ) svn:r17244 --- ChangeLog | 6 ++++++ src/common/compat.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c9e8c416d..116ad1c7c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Changes in version 0.2.1.8-alpha - 2008-??-?? + o Minor bugfixes: + - Get file locking working on win32. Bugfix on 0.2.1.6-alpha. Fixes + bug 859. + + Changes in version 0.2.1.7-alpha - 2008-11-08 o Security fixes: - The "ClientDNSRejectInternalAddresses" config option wasn't being diff --git a/src/common/compat.c b/src/common/compat.c index b3d4361969..5a3858ef8a 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -508,7 +508,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, 0) < 0) { + if (_locking(fd, blocking ? _LK_LOCK : _LK_NBLCK, 1) < 0) { if (errno != EDEADLOCK) log_warn(LD_FS,"Couldn't lock \"%s\": %s", filename, strerror(errno)); else @@ -542,7 +542,7 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile) log_info(LD_FS, "Unlocking \"%s\"", lockfile->filename); #ifdef WIN32 _lseek(lockfile->fd, 0, SEEK_SET); - if (_locking(lockfile->fd, _LK_UNLCK, 0) < 0) { + if (_locking(lockfile->fd, _LK_UNLCK, 1) < 0) { log_warn(LD_FS,"Error unlocking \"%s\": %s", lockfile->filename, strerror(errno)); } -- 2.11.4.GIT