summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-27 17:08:25 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-27 17:08:25 +0000
commitc180e0d8801a8fb1f4d900d6a7e36ccb7d4f557e (patch)
tree72aa6ff633585ad3c5c06422bc3554b2ff002e25
parentf79ddbebe390cd4216bfe35e2b33aae764dee648 (diff)
* vm_trace.c (rb_postponed_job_register_one): fix iteration bug.
* ext/-test-/postponed_job/postponed_job.c, test/-ext-/postponed_job/test_postponed_job.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/-test-/postponed_job/postponed_job.c19
-rw-r--r--test/-ext-/postponed_job/test_postponed_job.rb3
-rw-r--r--vm_trace.c1
4 files changed, 30 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index bc0fa906097..228b48e2654 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue May 28 02:07:21 2013 Koichi Sasada <ko1@atdot.net>
+
+ * vm_trace.c (rb_postponed_job_register_one): fix iteration bug.
+
+ * ext/-test-/postponed_job/postponed_job.c,
+ test/-ext-/postponed_job/test_postponed_job.rb: add a test.
+
Tue May 28 00:34:23 2013 Koichi Sasada <ko1@atdot.net>
* include/ruby/ruby.h, gc.c: add new internal event
diff --git a/ext/-test-/postponed_job/postponed_job.c b/ext/-test-/postponed_job/postponed_job.c
index ac1bf808904..157230e33bb 100644
--- a/ext/-test-/postponed_job/postponed_job.c
+++ b/ext/-test-/postponed_job/postponed_job.c
@@ -17,6 +17,24 @@ pjob_register(VALUE self, VALUE obj)
return self;
}
+static void
+pjob_one_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+
+ rb_ary_push(ary, INT2FIX(1));
+}
+
+static VALUE
+pjob_register_one(VALUE self, VALUE obj)
+{
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ return self;
+}
+
static VALUE
pjob_call_direct(VALUE self, VALUE obj)
{
@@ -29,6 +47,7 @@ Init_postponed_job(VALUE self)
{
VALUE mBug = rb_define_module("Bug");
rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
+ rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
}
diff --git a/test/-ext-/postponed_job/test_postponed_job.rb b/test/-ext-/postponed_job/test_postponed_job.rb
index cf32eb7bd36..b1111ba330f 100644
--- a/test/-ext-/postponed_job/test_postponed_job.rb
+++ b/test/-ext-/postponed_job/test_postponed_job.rb
@@ -21,5 +21,8 @@ class TestPostponed_job < Test::Unit::TestCase
assert_match /postponed_job_call_direct_wrapper/, direct.join
assert_not_match /postponed_job_register_wrapper/, registered.join
+
+ Bug.postponed_job_register_one(ary = [])
+ assert_equal [1], ary
end
end
diff --git a/vm_trace.c b/vm_trace.c
index 78113e21683..d0bcc3a498b 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1415,6 +1415,7 @@ rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func,
if (pjob->func == func) {
return 2;
}
+ pjob = pjob->next;
}
return rb_postponed_job_register(flags, func, data);