Kouhei Sutou
null+****@clear*****
Sat Aug 16 13:35:45 JST 2014
Kouhei Sutou 2014-08-16 13:35:45 +0900 (Sat, 16 Aug 2014) New Revision: 06a09f1712676e3c3d260e597366a199e021863c https://github.com/ranguba/rroonga/commit/06a09f1712676e3c3d260e597366a199e021863c Message: Split running finalizer phase and unbind phase Because some objects don't have finalizer but they should be unbound related Groonga objects to detect whether the Groonga object is closed. Modified files: ext/groonga/rb-grn-object.c Modified: ext/groonga/rb-grn-object.c (+13 -0) =================================================================== --- ext/groonga/rb-grn-object.c 2014-08-16 13:34:55 +0900 (f1ff83d) +++ ext/groonga/rb-grn-object.c 2014-08-16 13:35:45 +0900 (8ec884c) @@ -160,6 +160,15 @@ rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object, grn_object->header.type); break; } +} + +static void +rb_grn_object_unbind (RbGrnObject *rb_grn_object) +{ + debug("unbind: %p:%p:%p %s(%#x)\n", + rb_grn_object->context, rb_grn_object->object, rb_grn_object, + rb_grn_inspect_type(rb_grn_object->object->header.type), + rb_grn_object->object->header.type); rb_grn_object->rb_grn_context = NULL; rb_grn_object->context = NULL; @@ -180,6 +189,7 @@ rb_grn_object_finalizer (grn_ctx *context, int n_args, grn_obj **grn_objects, grn_obj_user_data(context, grn_object)->ptr = NULL; rb_grn_object_run_finalizer(context, grn_object, rb_grn_object); + rb_grn_object_unbind(rb_grn_object); return NULL; } @@ -213,6 +223,7 @@ rb_grn_object_free (RbGrnObject *rb_grn_object) } else { rb_grn_object_run_finalizer(context, grn_object, rb_grn_object); } + rb_grn_object_unbind(rb_grn_object); } if (rb_grn_object->need_close) { grn_obj_unlink(context, grn_object); @@ -580,6 +591,7 @@ rb_grn_object_close (VALUE self) if (rb_grn_object->have_finalizer) { rb_grn_object_run_finalizer(context, object, rb_grn_object); } + rb_grn_object_unbind(rb_grn_object); grn_obj_close(context, object); } @@ -604,6 +616,7 @@ rb_grn_object_unlink (VALUE self) if (object && context) { if (!(rb_grn_object->object->header.flags & GRN_OBJ_PERSISTENT)) { rb_grn_object_run_finalizer(context, object, rb_grn_object); + rb_grn_object_unbind(rb_grn_object); } grn_obj_unlink(context, object); } -------------- next part -------------- HTML����������������������������... ダウンロード