From ba5d195a288e797b8c14293ce3dca664e4e6bf27 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Wed, 27 May 2015 20:12:38 +0000
Subject: [PATCH] ext/openssl/lib/openssl/ssl.rb: use io/nonblock instead of
 fcntl

IO#nonblock= is easier-to-read, potentially more portable, and
avoids redundantly setting flags.
---
 ext/openssl/lib/openssl/ssl.rb | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index 0cab141..cc956fa 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -15,7 +15,7 @@
 =end
 
 require "openssl/buffering"
-require "fcntl"
+require "io/nonblock"
 
 module OpenSSL
   module SSL
@@ -126,9 +126,7 @@ module OpenSSL
 
     module Nonblock
       def initialize(*args)
-        flag = File::NONBLOCK
-        flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
-        @io.fcntl(Fcntl::F_SETFL, flag)
+        @io.nonblock = true if @io.respond_to?(:nonblock=)
         super
       end
     end
-- 
EW

