From 49a2b019f645a161d4f5c2a0b0075eedd95df9fd Mon Sep 17 00:00:00 2001 From: usa Date: Sat, 4 Feb 2006 12:21:55 +0000 Subject: * win32/win32.c (LK_ERR): ERROR_NOT_LOCKED is not an error. In such situation, flock() should return 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ win32/win32.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b117c809f7..9e2032a0b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Feb 4 21:19:23 2006 NAKAMURA Usaku + + * win32/win32.c (LK_ERR): ERROR_NOT_LOCKED is not an error. + In such situation, flock() should return 0. + Sat Feb 4 15:56:37 2006 Hirokazu Yamamoto * numeric.c (fix_to_s): (2**32).to_s(2) fails with exception where diff --git a/win32/win32.c b/win32/win32.c index ef6886af2b..ce69f3b826 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -250,7 +250,20 @@ GetCurrentThreadHandle(void) /* simulate flock by locking a range on the file */ -#define LK_ERR(f,i) ((f) ? (i = 0) : (errno = GetLastError() == ERROR_LOCK_VIOLATION ? EWOULDBLOCK : EACCES)) +#define LK_ERR(f,i) \ + do { \ + if (f) \ + i = 0; \ + else { \ + DWORD err = GetLastError(); \ + if (err == ERROR_LOCK_VIOLATION) \ + errno = EWOULDBLOCK; \ + else if (err == ERROR_NOT_LOCKED) \ + i = 0; \ + else \ + errno = map_errno(err); \ + } \ + } while (0) #define LK_LEN ULONG_MAX static VALUE -- cgit v1.2.3