diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-24 13:51:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-24 13:51:59 +0000 |
commit | 4acc61313fbe98a7249acd6eff264e3d0c4209c4 (patch) | |
tree | 8a69ef0ba5afb4aa7411e15889b5141d8eecff4f /vm.c | |
parent | d3b2d870bfbb60955d914aa0a288f69fa9614c10 (diff) | |
download | ruby-4acc61313fbe98a7249acd6eff264e3d0c4209c4.tar.gz |
* vm.c (ruby_vm_destruct): run vm exit hooks after all objects are
destructed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -181,6 +181,19 @@ ruby_vm_at_exit(void (*func)(rb_vm_t *)) rb_ary_push((VALUE)&GET_VM()->at_exit, (VALUE)func); } +static void +ruby_vm_run_at_exit_hooks(rb_vm_t *vm) +{ + VALUE hook = (VALUE)&vm->at_exit; + + while (RARRAY_LEN(hook) > 0) { + typedef void rb_vm_at_exit_func(rb_vm_t*); + rb_vm_at_exit_func *func = (rb_vm_at_exit_func*)rb_ary_pop(hook); + (*func)(vm); + } + rb_ary_free(hook); +} + /* Env */ /* @@ -1550,6 +1563,7 @@ ruby_vm_destruct(rb_vm_t *vm) rb_objspace_free(objspace); } #endif + ruby_vm_run_at_exit_hooks(vm); rb_vm_gvl_destroy(vm); ruby_xfree(vm); ruby_current_vm = 0; |