summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-27 07:00:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-27 07:00:26 +0000
commitfbbd7e29e7b7cb6a38cc3fa05a11c869f9fe028c (patch)
treef93d1a4382c99168ca1a6600402a95c641e13250 /ext
parentd907adecd9267d6cddb77d1fd7c4c6fcb878772e (diff)
* ext/socket/extconf.rb (test_recvmsg_with_msg_peek_creates_fds):
Extracted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb97
1 files changed, 49 insertions, 48 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index b933334..0bd1371 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -242,6 +242,52 @@ int main(int argc, char *argv[])
}
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
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