Backport #5664
closedWebrick broken FD_CLOEXEC
Description
ruby-1.8.7-p352 $ grep -R CLOEXEC .
./ext/fcntl/fcntl.c: * - FD_CLOEXEC - the value of the close-on-exec flag.
./ext/fcntl/fcntl.c:#ifdef FD_CLOEXEC
./ext/fcntl/fcntl.c: rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
./lib/drb/drb.rb: soc.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
./lib/drb/unix.rb: soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/resolv.rb: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::F_SETFD
./lib/webrick/utils.rb: if defined?(Fcntl::FD_CLOEXEC)
./lib/webrick/utils.rb: io.fcntl(Fcntl::FD_CLOEXEC, 1)
There you can see lots of examples of FD_CLOEXEC being used correctly: fcntl (command F_SETFD, value FD_CLOEXEC)
But in the last line, Webrick is calling fcntl wrongly: it is calling command FD_CLOEXEC with value 1 !! So what it's actually calling is command F_GETFD, which does nothing.
Fcntl.constants.select { |x| Fcntl.const_get(x) == Fcntl::FD_CLOEXEC }
=> ["F_GETFD", "FD_CLOEXEC", "O_WRONLY", "F_RDLCK"]
I have checked this in the latest 1.8.7-p352 source too, and it's the same there.
Updated by akr (Akira Tanaka) about 13 years ago
- ruby -v changed from ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] to -
2011/11/23 Brian Candler b.candler@pobox.com:
Bug #5664: Webrick broken FD_CLOEXEC
http://redmine.ruby-lang.org/issues/5664
./lib/drb/unix.rb: soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
./lib/webrick/utils.rb: io.fcntl(Fcntl::FD_CLOEXEC, 1)
There you can see lots of examples of FD_CLOEXEC being used correctly: fcntl (command F_SETFD, value FD_CLOEXEC)
But in the last line, Webrick is calling fcntl wrongly: it is calling command FD_CLOEXEC with value 1 !! So what it's actually calling is command F_GETFD, which does nothing.
I fixed them (not only webrick/utils.rb but also drb/unix.rb) at r33611
for trunk and 1.8 branch.
It seems not backported yet.¶
Tanaka Akira
Updated by naruse (Yui NARUSE) about 13 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby 1.8 to Backport187
- Status changed from Open to Assigned
- Assignee set to shyouhei (Shyouhei Urabe)
Updated by shyouhei (Shyouhei Urabe) about 8 years ago
- Status changed from Assigned to Closed