summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-06 07:06:22 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-06 07:06:22 +0000
commit506ddf9bba9622a2506d4eec0adb7732c45c9a28 (patch)
treeb8a09c86c5085c331fd3febed839d4252dfd45c0 /file.c
parent0af338d4322d9686687a4f5bfc16f88ff900bc42 (diff)
downloadruby-506ddf9bba9622a2506d4eec0adb7732c45c9a28.tar.gz
ruby-506ddf9bba9622a2506d4eec0adb7732c45c9a28.tar.xz
ruby-506ddf9bba9622a2506d4eec0adb7732c45c9a28.zip
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
In such situation, flock() should return 0. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/file.c b/file.c
index 698172a3f..176e2e57e 100644
--- a/file.c
+++ b/file.c
@@ -2230,7 +2230,7 @@ rb_file_s_rename(klass, from, to)
dst = StringValueCStr(to);
if (rename(src, dst) < 0) {
#if defined __CYGWIN__
- extern unsigned long __attribute__((stdcall)) GetLastError();
+ extern unsigned long __attribute__((stdcall)) GetLastError(void);
errno = GetLastError(); /* This is a Cygwin bug */
#elif defined DOSISH && !defined _WIN32
if (errno == EEXIST
@@ -3107,7 +3107,19 @@ rb_file_truncate(obj, len)
# define LOCK_UN 8
# endif
-#if 1
+#ifdef __CYGWIN__
+static int
+#include <winerror.h>
+cygwin_flock(int fd, int op)
+{
+ int ret = flock(fd, op);
+ if (GetLastError() == ERROR_NOT_LOCKED)
+ ret = 0;
+ return ret;
+}
+# define flock(fd, op) cygwin_flock(fd, op)
+#endif
+
static int
rb_thread_flock(fd, op, fptr)
int fd, op;
@@ -3137,8 +3149,10 @@ rb_thread_flock(fd, op, fptr)
}
return 0;
}
-#define flock(fd, op) rb_thread_flock(fd, op, fptr)
+#ifdef __CYGWIN__
+# undef flock
#endif
+#define flock(fd, op) rb_thread_flock(fd, op, fptr)
/*
* call-seq: