[#1147] Copying RVALUE — why the lucky stiff <ruby-core@...>

Hello, everyone. Hope you are all doing well.

18 messages 2003/06/17
[#1155] Re: Copying RVALUE — matz@... (Yukihiro Matsumoto) 2003/06/20

Hi,

[#1157] Re: Copying RVALUE — why the lucky stiff <ruby-core@...> 2003/06/20

Yukihiro Matsumoto (matz@ruby-lang.org) wrote:

[#1173] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...>

Hi, I'm new to this mailing list so I don't know the procedure for

15 messages 2003/06/22
[#1174] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1175] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/22

On Sun, 2003-06-22 at 05:36, nobu.nokada@softhome.net wrote:

[#1176] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — nobu.nokada@... 2003/06/22

Hi,

[#1193] Re: [Patch] class.c code cleanup (rb_class_*_instance_methods) — Matthew Dempsky <jivera@...> 2003/06/25

On Sun, 2003-06-22 at 07:41, nobu.nokada@softhome.net wrote:

[#1177] Re: In 1.8.0 nil.to_s is not the same as "" — ts <decoux@...>

14 messages 2003/06/22

ext/gdbm and multiple readers at a time

From: Mauricio Fern疣dez <batsman.geo@...>
Date: 2003-06-03 11:49:23 UTC
List: ruby-core #1115
man gdbm says

A  process that opens a gdbm file is designated as a "reader" or a
"writer".  Only one writer may open a gdbm file and many readers
                                                    ============ 
may open the file.  Readers and writers can not open the gdbm
file at the same time.

However the gdbm extension didn't seem to allow that.
I ended up doing the following:

--- ruby-1.8.0.orig/ext/gdbm/gdbm.c     Tue Jun  3 13:25:17 2003
+++ ruby-1.8.0/ext/gdbm/gdbm.c  Tue Jun  3 13:27:17 2003
@@ -97,6 +97,8 @@

     if (!NIL_P(vflags))
         flags = NUM2INT(vflags);
+    else
+           flags = GDBM_READER;

     SafeStringValue(file);

@@ -106,10 +108,7 @@
                        GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC);
     if (!dbm)
        dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
-                       GDBM_WRITER|flags, 0, MY_FATAL_FUNC);
-    if (!dbm)
-       dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
-                       GDBM_READER|flags, 0, MY_FATAL_FUNC);
+                       flags, 0, MY_FATAL_FUNC);

     if (!dbm) {
        if (mode == -1) return Qnil;
@@ -974,12 +973,12 @@
     rb_define_method(rb_cGDBM, "to_hash", fgdbm_to_hash, 0);

     /* flags for gdbm_opn() */
-    /*
+
     rb_define_const(rb_cGDBM, "READER",  INT2FIX(GDBM_READER));
     rb_define_const(rb_cGDBM, "WRITER",  INT2FIX(GDBM_WRITER));
     rb_define_const(rb_cGDBM, "WRCREAT", INT2FIX(GDBM_WRCREAT));
     rb_define_const(rb_cGDBM, "NEWDB",   INT2FIX(GDBM_NEWDB));
-    */
+
     rb_define_const(rb_cGDBM, "FAST", INT2FIX(GDBM_FAST));
     /* this flag is obsolete in gdbm 1.8.
        On gdbm 1.8, fast mode is default behavior. */


Now I can do
  require 'gdbm'
  GDBM.open("something.db", GDBM::READER) do |db|
	.... = db["bla"]
  end

in several processes/threads at a time.

My patch is so simple there must be something wrong about it, otherwise
it'd be in Ruby already :-P

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

We apologize for the inconvenience, but we'd still like yout to test out
this kernel. 
	-- Linus Torvalds, announcing another kernel patch

In This Thread

Prev Next