ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:86655] cross-thread IO#close semantics
Date: Mon, 23 Apr 2018 13:39:46 +0000
Message-ID: <20180423133946.GA6019@dcvr> (raw)

Related to the discussion on [Bug #14681]

I found an old Ruby 1.8 installation, and the following code
exits after 100ms with: [IOError, "stream closed"]
1.9 and later hangs forever:

  r, w = IO.pipe
  th = Thread.new do
    begin
      IO.select([r])
    rescue => e
      warn [ e.class, e.message ].inspect
    end
  end
  sleep 0.1
  r.close
  th.join

Of course I know why: it's not implemented in 1.9+;
rb_thread_io_blocking_region only cares for operations on the
single FD case, multiplexing functions like select aren't
supported.  I could implement it, but it has overhead and maybe
nobody cares for this feature.  IO.select is an inefficient API
anyways

This also pertains to [Feature #13618] for auto-fiber/green thread
support or whatever it will be called.

If I replace IO.select with single FD operation which hits
rb_thread_io_blocking_region in 1.9+ such as "r.read", then Ruby
behaves consistently in 1.8/1.9/2.x


             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 13:39 Eric Wong [this message]
2018-05-15  9:53 ` [ruby-core:87040] " Eric Wong

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180423133946.GA6019@dcvr \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ruby-core@ruby-lang.org archive (unofficial mirror)

Archives are clonable: git clone --mirror https://public-inbox.org/ruby-core

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.core
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.core
	nntp://news.gmane.org/gmane.comp.lang.ruby.core

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox