[#9445] thread.rb — m_seki@...

18 messages 2000/03/16
[#9446] Re: thread.rb — matz@... (Yukihiro Matsumoto) 2000/03/17

[#9460] Re: thread.rb — m_seki@... 2000/03/21

[#9462] Re: thread.rb — matz@... (Yukihiro Matsumoto) 2000/03/21

まつもと ゆきひろです

[#11281] Re: thread.rb — Masatoshi SEKI <m_seki@...> 2000/10/22

[#9498] timeout しない timeout — ARIMA Yasuhiro <fit0298@...>

有馬です。

20 messages 2000/03/26
[#9506] Re: timeout しない timeout — matz@... (Yukihiro Matsumoto) 2000/03/27

まつもと ゆきひろです

[#9509] Re: timeout しない timeout — gotoken@... (GOTO Kentaro) 2000/03/27

In message "[ruby-dev:9506] Re: timeout しない timeout"

[ruby-dev:9414] Re: [ruby-list:21257] Re: flock in PStore

From: WATANABE Hirofumi <eban@...>
Date: 2000-03-08 16:43:27 UTC
List: ruby-dev #9414
わたなべです.

ruby-dev に移ります.

Yukihiro Matsumoto <matz@netlab.co.jp> writes:

:|win32/win32.c の flock を使うか,
:
:あれ? win32.cにもflockあるんですね。multiply defined になら
:ないんでしょうか?

mswin32 では configure しないから.

:|どうせなら perl の fcntl_emulate_flock をパクってきて,
:|missing/flock.c に fcntl の処理も入れたほうがいいかな?
:
:パッチ歓迎。

lib/pstore.rb の sample で sleep 10 を入れて試したら ok でした.

Thu Mar  9 01:36:32 2000  WATANABE Hirofumi  <eban@os.rim.or.jp>

	* missing/flock.c: emulate missing flock() with fcntl().


--- missing/flock.c.orig	Fri Jan 16 21:13:08 1998
+++ missing/flock.c	Thu Mar 09 01:20:24 2000
@@ -80,2 +80,50 @@
 }
+#elif defined HAVE_FCNTL && defined HAVE_FCNTL_H
+
+/* These are the flock() constants.  Since this sytems doesn't have
+   flock(), the values of the constants are probably not available.
+*/
+# ifndef LOCK_SH
+#  define LOCK_SH 1
+# endif
+# ifndef LOCK_EX
+#  define LOCK_EX 2
+# endif
+# ifndef LOCK_NB
+#  define LOCK_NB 4
+# endif
+# ifndef LOCK_UN
+#  define LOCK_UN 8
+# endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+flock(fd, operation)
+    int fd;
+    int operation;
+{
+    struct flock lock;
+ 
+    switch (operation & ~LOCK_NB) {
+    case LOCK_SH:
+	lock.l_type = F_RDLCK;
+	break;
+    case LOCK_EX:
+	lock.l_type = F_WRLCK;
+	break;
+    case LOCK_UN:
+	lock.l_type = F_UNLCK;
+	break;
+    default:
+	errno = EINVAL;
+	return -1;
+    }
+    lock.l_whence = SEEK_SET;
+    lock.l_start = lock.l_len = 0L;
+ 
+    return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
+}
 #else

In This Thread

Prev Next