diff options
| author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-04 12:21:55 +0000 |
|---|---|---|
| committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-02-04 12:21:55 +0000 |
| commit | 46d3a078abbe026bc963f7325c581796a3f05fb8 (patch) | |
| tree | 977ac12d326d26cc037ee08fe196d50f7c22c893 /win32 | |
| parent | 7f22329eddf873c1135957d75f6c7d89dbe33622 (diff) | |
| download | ruby-46d3a078abbe026bc963f7325c581796a3f05fb8.tar.gz ruby-46d3a078abbe026bc963f7325c581796a3f05fb8.tar.xz ruby-46d3a078abbe026bc963f7325c581796a3f05fb8.zip | |
* win32/win32.c (LK_ERR): ERROR_NOT_LOCKED is not an error.
In such situation, flock() should return 0.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/win32.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index ef6886af2..ce69f3b82 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 |
