1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* cont.c (rb_fiber_m_transfer, rb_fiber_resume): prohibit using

"resume" after "transfer" method are used.  You should not mix
  "resume" fiber and "transfer" fiber.
  [Bug #5526]
* NEWS: add information about this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2011-11-09 04:26:39 +00:00
parent b2c44e7af5
commit 9cd8b76e6d
3 changed files with 27 additions and 2 deletions

View file

@ -1,3 +1,12 @@
Thu Nov 10 05:17:25 2011 Koichi Sasada <ko1@atdot.net>
* cont.c (rb_fiber_m_transfer, rb_fiber_resume): prohibit using
"resume" after "transfer" method are used. You should not mix
"resume" fiber and "transfer" fiber.
[Bug #5526]
* NEWS: add information about this change.
Wed Nov 9 11:40:37 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* template/Doxyfile.tmpl (INCLUDE_PATH): add srcdir and include.

4
NEWS
View file

@ -32,6 +32,10 @@ with all sufficient information, see the ChangeLog file.
* Time#to_s returned encoding defaults to US-ASCII but automatically
transcodes to Encoding.default_internal if it is set.
* Fiber
* incompatible changes:
* Fiber#resume cannot resume a fiber which invokes "Fiber#transfer".
* net/imap
* new methods:
* Net::IMAP.default_port

16
cont.c
View file

@ -103,6 +103,12 @@ typedef struct rb_fiber_struct {
enum fiber_status status;
struct rb_fiber_struct *prev_fiber;
struct rb_fiber_struct *next_fiber;
/* If a fiber invokes "transfer",
* then this fiber can't "resume" any more after that.
* You shouldn't mix "transfer" and "resume".
*/
int transfered;
#if FIBER_USE_NATIVE
#ifdef _WIN32
void *fib_handle;
@ -1322,6 +1328,9 @@ rb_fiber_resume(VALUE fibval, int argc, VALUE *argv)
if (fib->prev != Qnil || fib->cont.type == ROOT_FIBER_CONTEXT) {
rb_raise(rb_eFiberError, "double resume");
}
if (fib->transfered != 0) {
rb_raise(rb_eFiberError, "cannot resume transferred Fiber");
}
return fiber_switch(fibval, argc, argv, 1);
}
@ -1389,9 +1398,12 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
* back to this fiber before it can yield and resume.
*/
static VALUE
rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fib)
rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fibval)
{
return rb_fiber_transfer(fib, argc, argv);
rb_fiber_t *fib;
GetFiberPtr(fibval, fib);
fib->transfered = 1;
return rb_fiber_transfer(fibval, argc, argv);
}
/*