From 56e982d447624a9cef62e2d676719ed190f8c206 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 26 Apr 2013 09:42:14 +0000 Subject: [PATCH] * ext/socket/extconf.rb: Use a block of enable_config() for --{enable,disable}-close-fds-by-recvmsg-with-peek configure option git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++ ext/socket/extconf.rb | 96 ++++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bc60442a9..5275165b13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Apr 26 18:41:04 2013 Tanaka Akira + + * ext/socket/extconf.rb: Use a block of enable_config() for + --{enable,disable}-close-fds-by-recvmsg-with-peek configure option + Fri Apr 26 18:08:08 2013 Tanaka Akira * dir.c (dir_set_pos): Fix a compilation error when seekdir() is not diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 50283ec3b3..b9333340a1 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -427,59 +427,57 @@ EOS } end - case enable_config("close-fds-by-recvmsg-with-peek") - when true - $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK" - when false - # nothing to do. - else - 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 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." - 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 - else - if close_fds == true - warn "unexpected 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." - end + 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 - end - if close_fds == nil - abort <