Kouhei Sutou
null+****@clear*****
Sun Aug 17 00:14:47 JST 2014
Kouhei Sutou 2014-08-17 00:14:47 +0900 (Sun, 17 Aug 2014) New Revision: 82180a766288f7ed3a59e10df8dfda776df0f767 https://github.com/ranguba/rroonga/commit/82180a766288f7ed3a59e10df8dfda776df0f767 Message: Avoid double unbind Modified files: ext/groonga/rb-grn-object.c Modified: ext/groonga/rb-grn-object.c (+17 -14) =================================================================== --- ext/groonga/rb-grn-object.c 2014-08-16 15:21:07 +0900 (f7cb5a8) +++ ext/groonga/rb-grn-object.c 2014-08-17 00:14:47 +0900 (5536495) @@ -88,6 +88,19 @@ rb_grn_object_from_ruby_object (VALUE object, grn_ctx **context) } 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; + rb_grn_object->object = NULL; +} + +static void rb_grn_object_run_finalizer (grn_ctx *context, grn_obj *grn_object, RbGrnObject *rb_grn_object) { @@ -160,19 +173,8 @@ 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; - rb_grn_object->object = NULL; + rb_grn_object_unbind(rb_grn_object); } static grn_obj * @@ -189,7 +191,6 @@ 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; } @@ -223,6 +224,7 @@ rb_grn_object_free (RbGrnObject *rb_grn_object) } else { rb_grn_object_run_finalizer(context, grn_object, rb_grn_object); } + } else { rb_grn_object_unbind(rb_grn_object); } if (rb_grn_object->need_close) { @@ -588,8 +590,9 @@ rb_grn_object_close (VALUE self) if (object && context) { if (rb_grn_object->have_finalizer) { rb_grn_object_run_finalizer(context, object, rb_grn_object); + } else { + rb_grn_object_unbind(rb_grn_object); } - rb_grn_object_unbind(rb_grn_object); grn_obj_close(context, object); } -------------- next part -------------- HTML����������������������������... Download