[前][次][番号順一覧][スレッド一覧]

ruby-changes:28427

From: akr <ko1@a...>
Date: Fri, 26 Apr 2013 18:42:26 +0900 (JST)
Subject: [ruby-changes:28427] akr:r40479 (trunk): * ext/socket/extconf.rb: Use a block of enable_config() for

akr	2013-04-26 18:42:14 +0900 (Fri, 26 Apr 2013)

  New Revision: 40479

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40479

  Log:
    * ext/socket/extconf.rb: Use a block of enable_config() for
      --{enable,disable}-close-fds-by-recvmsg-with-peek configure option

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/extconf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40478)
+++ ChangeLog	(revision 40479)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr 26 18:41:04 2013  Tanaka Akira  <akr@f...>
+
+	* 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  <akr@f...>
 
 	* dir.c (dir_set_pos): Fix a compilation error when seekdir() is not
Index: ext/socket/extconf.rb
===================================================================
--- ext/socket/extconf.rb	(revision 40478)
+++ ext/socket/extconf.rb	(revision 40479)
@@ -427,59 +427,57 @@ EOS https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L427
     }
   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
+        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
-          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."
+          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
-          close_fds = false
         end
-      end
-      if close_fds == nil
-        abort <<EOS
-Fatal: cannot test recvmsg() with MSG_PEEK allocate file descriptors or not
-because cross-compilation.
-Specify a configure option.
+        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
-      if close_fds
-        $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
-      end
-    end
+     }
+    $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
   end
 
   case enable_config("wide-getaddrinfo")
@@ -488,7 +486,10 @@ EOS https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L486
   when nil
     if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
       getaddr_info_ok = :os
-      if !CROSS_COMPILING && !checking_for("system getaddrinfo working") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
+      if !CROSS_COMPILING &&
+         !checking_for("system getaddrinfo working") {
+           try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)
+         }
         getaddr_info_ok = :wide
       end
     else
@@ -497,7 +498,10 @@ EOS https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L498
   when false
     if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
       getaddr_info_ok = :os
-      if !CROSS_COMPILING && !checking_for("system getaddrinfo working") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
+      if !CROSS_COMPILING &&
+         !checking_for("system getaddrinfo working") {
+           try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)
+         }
         getaddr_info_ok = nil
       end
     else

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]