rallhook 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Rakefile +1 -1
- data/ext/rallhook_base/rallhook.c +14 -12
- data/lib/rallhook.rb +2 -9
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.7.2 Fixed issue 9 by ruby-wrapping properly the rallhook thread info including the garbage collector mark function of
|
2
|
+
the ruby wrapper
|
3
|
+
|
4
|
+
Removed hotfix of issue 9 improved in version 0.7.1, thread support restored
|
5
|
+
|
1
6
|
0.7.1 Fixed issue 9 ( http://github.com/tario/rallhook/issues#issue/9 ), "broken" object is processed by the GC due the impossibility of avoid
|
2
7
|
the deletion of an object of class Redirect returned by handle_method. The hotfix disabled the GC at each redirection and enable
|
3
8
|
it again each time that a WRAPPER redirection concludes. Also the GC are re-enabled when the hook block is terminated.
|
data/Rakefile
CHANGED
@@ -72,6 +72,11 @@ typedef struct AttachedThreadInfo_ {
|
|
72
72
|
int handle_method_arity;
|
73
73
|
} AttachedThreadInfo;
|
74
74
|
|
75
|
+
|
76
|
+
void tinfo_mark(AttachedThreadInfo* tinfo) {
|
77
|
+
rb_gc_mark(tinfo->hook_proc);
|
78
|
+
}
|
79
|
+
|
75
80
|
AttachedThreadInfo* tinfo_from_thread(VALUE thread) {
|
76
81
|
VALUE tmp = rb_ivar_get( thread, rb_intern("__tinfo") );
|
77
82
|
|
@@ -81,11 +86,17 @@ AttachedThreadInfo* tinfo_from_thread(VALUE thread) {
|
|
81
86
|
tinfo->hook_enable_left = 0;
|
82
87
|
tinfo->hook_proc = Qnil;
|
83
88
|
|
84
|
-
|
89
|
+
VALUE tinfo_obj = Data_Make_Struct(rb_cObject, AttachedThreadInfo, tinfo_mark, free, tinfo);
|
90
|
+
|
91
|
+
rb_ivar_set( thread, rb_intern("__tinfo"), tinfo_obj);
|
85
92
|
|
86
93
|
return tinfo;
|
87
94
|
} else {
|
88
|
-
|
95
|
+
|
96
|
+
AttachedThreadInfo* tinfo;
|
97
|
+
Data_Get_Struct(tmp, AttachedThreadInfo, tinfo);
|
98
|
+
|
99
|
+
return tinfo;
|
89
100
|
}
|
90
101
|
}
|
91
102
|
|
@@ -117,12 +128,6 @@ VALUE get_hook_proc() {
|
|
117
128
|
Disable the hook. Is not usually necesary because of the RAII feature of Hook#hook
|
118
129
|
*/
|
119
130
|
VALUE unhook(VALUE self) {
|
120
|
-
disable_redirect(tinfo_from_thread( rb_thread_current() ) );
|
121
|
-
rb_gc_enable();
|
122
|
-
return Qnil;
|
123
|
-
}
|
124
|
-
|
125
|
-
VALUE restore_unhook(VALUE self) {
|
126
131
|
disable_redirect(tinfo_from_thread( rb_thread_current() ) );
|
127
132
|
return Qnil;
|
128
133
|
}
|
@@ -197,9 +202,6 @@ void rallhook_redirect_handler ( VALUE* klass, VALUE* recv, ID* mid ) {
|
|
197
202
|
|
198
203
|
// method named "binding" cannot be redirected
|
199
204
|
if (rb_obj_is_kind_of(result,rb_mMethodRedirect) == Qtrue ) {
|
200
|
-
|
201
|
-
rb_gc_disable();
|
202
|
-
|
203
205
|
*klass = rb_ivar_get(result,id_klass_var );
|
204
206
|
*recv = rb_ivar_get(result,id_recv_var );
|
205
207
|
*mid = rb_to_id( rb_ivar_get(result,id_method_var) );
|
@@ -266,7 +268,7 @@ If no call to Hook#hook has made, rehook does nothing
|
|
266
268
|
VALUE rehook(VALUE unused) {
|
267
269
|
enable_redirect(tinfo_from_thread( rb_thread_current() ));
|
268
270
|
if (rb_block_given_p() ) {
|
269
|
-
return rb_ensure(rb_yield, Qnil,
|
271
|
+
return rb_ensure(rb_yield, Qnil, unhook, Qnil);
|
270
272
|
}
|
271
273
|
return Qnil;
|
272
274
|
}
|
data/lib/rallhook.rb
CHANGED
@@ -40,7 +40,7 @@ module RallHook
|
|
40
40
|
#
|
41
41
|
class Redirect
|
42
42
|
include MethodRedirect
|
43
|
-
|
43
|
+
|
44
44
|
attr_reader :recv
|
45
45
|
|
46
46
|
def initialize(klass, recv, m, unhook = nil)
|
@@ -225,8 +225,7 @@ module RallHook
|
|
225
225
|
call(*args)
|
226
226
|
end
|
227
227
|
ensure
|
228
|
-
|
229
|
-
::RallHook::Hook.rehook
|
228
|
+
rehook
|
230
229
|
end
|
231
230
|
|
232
231
|
#
|
@@ -326,11 +325,6 @@ class Object
|
|
326
325
|
# Anyway, it is desirable to use MethodWrapper instead to "wrap" method calls
|
327
326
|
#
|
328
327
|
# see RallHook::Helper::MethodWrapper
|
329
|
-
#
|
330
|
-
# NOTE: Rallhook internally disable the GC in a redirection, you must reactivate it after
|
331
|
-
#
|
332
|
-
# NOTE 2: If use the MethodWrapper functionallity, it reactivates the GC disabled by rallhook. You should not
|
333
|
-
# worry about it
|
334
328
|
#
|
335
329
|
def redirect_with_unhook(method_name, klass = nil)
|
336
330
|
if klass
|
@@ -364,7 +358,6 @@ class Object
|
|
364
358
|
#
|
365
359
|
# # hook using MethodHandler, etc... (see README and examples)
|
366
360
|
#
|
367
|
-
# NOTE: Rallhook internally disable the GC in a redirection, you must reactivate it after
|
368
361
|
#
|
369
362
|
def redirect(method_name, klass = nil)
|
370
363
|
if klass
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rallhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dario Seminara
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-25 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|