Skip to content

Commit

Permalink
* vm_trace.c (exec_hooks_precheck): check need_clean everytime
Browse files Browse the repository at this point in the history
  to clean-up unused hooks.

* vm_trace.c (list->need_clean): use as boolean value.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Nov 7, 2015
1 parent d7924ab commit 1dd547f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
Sun Nov 8 08:10:31 2015 Koichi Sasada <ko1@atdot.net>

* vm_trace.c (exec_hooks_precheck): check need_clean everytime
to clean-up unused hooks.

* vm_trace.c (list->need_clean): use as boolean value.

Sun Nov 8 01:31:27 2015 NARUSE, Yui <naruse@ruby-lang.org>

* lib/net/http.rb (Net::HTTP#initialize):
Expand Down
11 changes: 5 additions & 6 deletions vm_trace.c
Expand Up @@ -171,7 +171,7 @@ remove_event_hook(rb_hook_list_t *list, rb_event_hook_func_t func, VALUE data)
if (data == Qundef || hook->data == data) {
hook->hook_flags |= RUBY_EVENT_HOOK_FLAG_DELETED;
ret+=1;
list->need_clean++;
list->need_clean = TRUE;
}
}
hook = hook->next;
Expand Down Expand Up @@ -230,7 +230,7 @@ clean_hooks(rb_hook_list_t *list)
rb_event_hook_t *hook, **nextp = &list->hooks;

list->events = 0;
list->need_clean = 0;
list->need_clean = FALSE;

while ((hook = *nextp) != 0) {
if (hook->hook_flags & RUBY_EVENT_HOOK_FLAG_DELETED) {
Expand Down Expand Up @@ -265,14 +265,13 @@ exec_hooks_body(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *tra
static int
exec_hooks_precheck(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg)
{
if ((list->events & trace_arg->event) == 0) return 0;

if (UNLIKELY(list->need_clean > 0)) {
if (UNLIKELY(list->need_clean != FALSE)) {
if (th->vm->trace_running <= 1) { /* only running this hooks */
clean_hooks(list);
}
}
return 1;

return (list->events & trace_arg->event) != 0;
}

static void
Expand Down

0 comments on commit 1dd547f

Please sign in to comment.