ruby-changes:28442
From: akr <ko1@a...>
Date: Sat, 27 Apr 2013 16:00:37 +0900 (JST)
Subject: [ruby-changes:28442] akr:r40494 (trunk): * ext/socket/extconf.rb (test_recvmsg_with_msg_peek_creates_fds):
akr 2013-04-27 16:00:26 +0900 (Sat, 27 Apr 2013) New Revision: 40494 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40494 Log: * ext/socket/extconf.rb (test_recvmsg_with_msg_peek_creates_fds): Extracted. Modified files: trunk/ChangeLog trunk/ext/socket/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 40493) +++ ChangeLog (revision 40494) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Apr 27 16:00:10 2013 Tanaka Akira <akr@f...> + + * ext/socket/extconf.rb (test_recvmsg_with_msg_peek_creates_fds): + Extracted. + Sat Apr 27 15:50:40 2013 Tanaka Akira <akr@f...> * internal.h (SIGNED_INTEGER_TYPE_P): New macro. Index: ext/socket/extconf.rb =================================================================== --- ext/socket/extconf.rb (revision 40493) +++ ext/socket/extconf.rb (revision 40494) @@ -242,6 +242,52 @@ int main(int argc, char *argv[]) https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L242 } EOF +def test_recvmsg_with_msg_peek_creates_fds(headers) + case RUBY_PLATFORM + when /linux/ + # Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK. + close_fds = true + when /bsd|darwin/ + # FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't + # allocate fds by recvmsg with MSG_PEEK. + # [ruby-dev:44189] + # http://bugs.ruby-lang.org/issues/5075 + close_fds = false + else + close_fds = nil + end + if !CROSS_COMPILING + if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") { + try_run(cpp_include(headers) + RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST) + } + if close_fds == false + warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation unexpected." + elsif close_fds == nil + puts "info: #{RUBY_PLATFORM} recvmsg() with MSG_PEEK allocates fds on fd-passing." + end + close_fds = true + else + if close_fds == true + warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation expected." + elsif close_fds == nil + puts "info: #{RUBY_PLATFORM}: recvmsg() with MSG_PEEK doesn't allocates fds on fd-passing." + end + close_fds = false + end + end + if close_fds == nil + abort <<EOS +Fatal: cannot test fd-passing recvmsg() with MSG_PEEK behavor +because cross-compilation for #{RUBY_PLATFORM}. +If recvmsg() with MSG_PEEK allocates fds on fd passing: +--enable-close-fds-by-recvmsg-with-peek +If recvmsg() with MSG_PEEK doesn't allocate fds on fd passing: +--disable-close-fds-by-recvmsg-with-peek +EOS + end + close_fds +end + $INCFLAGS << " -I$(topdir) -I$(top_srcdir)" headers = [] @@ -428,54 +474,9 @@ EOS https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L474 end if enable_config("close-fds-by-recvmsg-with-peek") { - if have_msg_control && have_recvmsg && - have_const('AF_UNIX', headers) && have_const('SCM_RIGHTS', headers) - case RUBY_PLATFORM - when /linux/ - # Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK. - close_fds = true - when /bsd|darwin/ - # FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't - # allocate fds by recvmsg with MSG_PEEK. - # [ruby-dev:44189] - # http://bugs.ruby-lang.org/issues/5075 - close_fds = false - else - close_fds = nil - end - if !CROSS_COMPILING - if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") { - try_run(cpp_include(headers) + RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST) - } - if close_fds == false - warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation unexpected." - elsif close_fds == nil - puts "info: #{RUBY_PLATFORM} recvmsg() with MSG_PEEK allocates fds on fd-passing." - end - close_fds = true - else - if close_fds == true - warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation expected." - elsif close_fds == nil - puts "info: #{RUBY_PLATFORM}: recvmsg() with MSG_PEEK doesn't allocates fds on fd-passing." - end - close_fds = false - end - end - if close_fds == nil - abort <<EOS -Fatal: cannot test fd-passing recvmsg() with MSG_PEEK behavor -because cross-compilation for #{RUBY_PLATFORM}. -If recvmsg() with MSG_PEEK allocates fds on fd passing: - --enable-close-fds-by-recvmsg-with-peek -If recvmsg() with MSG_PEEK doesn't allocate fds on fd passing: - --disable-close-fds-by-recvmsg-with-peek -EOS - end - close_fds - else - false - end + have_msg_control && have_recvmsg && + have_const('AF_UNIX', headers) && have_const('SCM_RIGHTS', headers) && + test_recvmsg_with_msg_peek_creates_fds(headers) } $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK" end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/