[Groonga-commit] ranguba/rroonga at a7447ea [master] Don't call Ruby method in unregistering floating object phase

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Aug 17 12:35:10 JST 2014


Kouhei Sutou	2014-08-17 12:35:10 +0900 (Sun, 17 Aug 2014)

  New Revision: a7447ea13e90ba88c999fc0dcf23ed776c641207
  https://github.com/ranguba/rroonga/commit/a7447ea13e90ba88c999fc0dcf23ed776c641207

  Message:
    Don't call Ruby method in unregistering floating object phase
    
    It may be called in GC.

  Modified files:
    ext/groonga/rb-grn-context.c
    ext/groonga/rb-grn-object.c
    ext/groonga/rb-grn.h

  Modified: ext/groonga/rb-grn-context.c (+2 -2)
===================================================================
--- ext/groonga/rb-grn-context.c    2014-08-17 12:32:14 +0900 (dba0904)
+++ ext/groonga/rb-grn-context.c    2014-08-17 12:35:10 +0900 (070ea7a)
@@ -1,6 +1,6 @@
 /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
-  Copyright (C) 2010-2012  Kouhei Sutou <kou �� clear-code.com>
+  Copyright (C) 2010-2014  Kouhei Sutou <kou �� clear-code.com>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -120,7 +120,7 @@ rb_grn_context_close_floating_objects (RbGrnContext *rb_grn_context)
     rb_grn_context->floating_objects = NULL;
     GRN_HASH_EACH(context, floating_objects, id, &floating_object, NULL, NULL, {
         (*floating_object)->floating = GRN_FALSE;
-        rb_funcall((*floating_object)->self, rb_intern("close"), 0);
+        rb_grn_object_close_raw(*floating_object);
     });
     grn_hash_close(context, floating_objects);
 }

  Modified: ext/groonga/rb-grn-object.c (+17 -10)
===================================================================
--- ext/groonga/rb-grn-object.c    2014-08-17 12:32:14 +0900 (5536495)
+++ ext/groonga/rb-grn-object.c    2014-08-17 12:35:10 +0900 (a1a157d)
@@ -571,20 +571,12 @@ rb_grn_object_deconstruct (RbGrnObject *rb_grn_object,
         *range = rb_grn_object->range;
 }
 
-/*
- * _object_ が使用しているリソースを開放する。これ以降 _object_ を
- * 使うことはできない。
- *
- * @overload close
- */
-VALUE
-rb_grn_object_close (VALUE self)
+void
+rb_grn_object_close_raw (RbGrnObject *rb_grn_object)
 {
-    RbGrnObject *rb_grn_object;
     grn_obj *object;
     grn_ctx *context;
 
-    rb_grn_object = SELF(self);
     rb_grn_object_deconstruct(rb_grn_object, &object, &context,
                               NULL, NULL, NULL, NULL);
     if (object && context) {
@@ -595,6 +587,21 @@ rb_grn_object_close (VALUE self)
         }
         grn_obj_close(context, object);
     }
+}
+
+/*
+ * _object_ が使用しているリソースを開放する。これ以降 _object_ を
+ * 使うことはできない。
+ *
+ * @overload close
+ */
+VALUE
+rb_grn_object_close (VALUE self)
+{
+    RbGrnObject *rb_grn_object;
+
+    rb_grn_object = SELF(self);
+    rb_grn_object_close_raw(rb_grn_object);
 
     return Qnil;
 }

  Modified: ext/groonga/rb-grn.h (+1 -0)
===================================================================
--- ext/groonga/rb-grn.h    2014-08-17 12:32:14 +0900 (470c5ba)
+++ ext/groonga/rb-grn.h    2014-08-17 12:35:10 +0900 (f7f3f35)
@@ -375,6 +375,7 @@ VALUE          rb_grn_object_set_raw                (RbGrnObject *rb_grn_object,
                                                      VALUE rb_value,
                                                      int flags,
                                                      VALUE related_object);
+void           rb_grn_object_close_raw              (RbGrnObject *rb_grn_object);
 VALUE          rb_grn_object_close                  (VALUE object);
 VALUE          rb_grn_object_closed_p               (VALUE object);
 VALUE          rb_grn_object_inspect_object         (VALUE inspected,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index