From fbbd7e29e7b7cb6a38cc3fa05a11c869f9fe028c Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 27 Apr 2013 07:00:26 +0000 Subject: * 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 --- ext/socket/extconf.rb | 97 ++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) (limited to 'ext/socket') diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index b9333340a1..0bd1371458 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 <