diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-30 17:39:48 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-30 17:39:48 +0000 |
commit | 279cd29b1b544cba09f5839d4abce81ab322d2c6 (patch) | |
tree | 2a0e983940bff674c5e52c7aa769d3dcde64eeba /thread.c | |
parent | 6ca32179e6d04cc6b22c4c2bbb55d3cc34127b3b (diff) |
* thread.c (rb_threadptr_interrupt_mask): add argument check.
* thread.c (async_interrupt_timing_arg_check_i): helper function
for the above.
* test/ruby/test_thread.rb (test_async_interrupt_timing_invalid_argument):
test for the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1545,12 +1545,27 @@ rb_threadptr_async_errinfo_active_p(rb_thread_t *th) return 1; } +static int +async_interrupt_timing_arg_check_i(VALUE key, VALUE val) +{ + VALUE immediate = ID2SYM(rb_intern("immediate")); + VALUE on_blocking = ID2SYM(rb_intern("on_blocking")); + VALUE defer = ID2SYM(rb_intern("defer")); + + if (val != immediate && val != on_blocking && val != defer) { + rb_raise(rb_eArgError, "unknown mask signature"); + } + + return ST_CONTINUE; +} + static VALUE rb_threadptr_interrupt_mask(rb_thread_t *th, VALUE mask, VALUE (*func)(rb_thread_t *th)) { VALUE r = Qnil; int state; + rb_hash_foreach(mask, async_interrupt_timing_arg_check_i, 0); rb_ary_push(th->async_errinfo_mask_stack, mask); if (!rb_threadptr_async_errinfo_empty_p(th)) { th->async_errinfo_queue_checked = 0; |