nobu.nokada
12/27/2004 1:03:00 AM
Hi,
At Mon, 27 Dec 2004 09:30:16 +0900,
Brent Roman wrote in [ruby-talk:124508]:
> If Thread.critical is set when readline is invoked, readline_event()
> will still schedule any other thread that becomes ready. This can
> cause another thread, that was not in a critical section, to interrupt
> one that was. So, now we have a thread becoming "critical"
> asynchronously. This leads to some very weird lockups -- some of which
> have been reported on this mailing list.
It would have to return immediately if rb_thread_critical is
set.
> I think a quick fix might be to remove the unconditional
> rb_thread_schedule() call from readline_event. But, a better
> fix is to remove the readline_event() function entirely.
>
> So, how will we avoid blocking other threads during keyboard reads?
> Replace readline_event() with this:
>
> static int
> readline_getc (ignored)
> FILE *ignored;
> {
> VALUE string = rb_funcall (rb_stdin, rb_intern("sysread"),
> 1, INT2FIX(1));
> return RSTRING(string)->ptr[0]; //single byte read
> }
>
>
> We redefine the function that GNU readline uses to read the input stream
> to be one based on Ruby's IO#sysread and let Ruby's own IO class
> deal with all its threading nastyness.
Do you mean to set it to rl_getc_function?
--
Nobu Nakada