+1 based on reviewing the diff, running the tests, and your comment in
#4649 that these flags aren't actually needed for the subset of
event-loop that we actually use.

-- 
Jacob Helwig

On Tue, 28 Sep 2010 11:25:39 -0700, Markus Roberts wrote:
> 
> MS Windows is apparently only "posix curious;" many of the usual fcntl flags
> are not defined when running under MS Windows.  It also appears that we are
> only using a small subset of the vendored event-loop library and could replace
> it with a handful of (portable) extracted methods.  This, however, would be
> too agressive of a refactor for 2.6.2 and so this commit simply avoids 
> referring
> to the unsupported flag values in environments where they are not defined.
> 
> Signed-off-by: Markus Roberts <[email protected]>
> ---
>  lib/puppet/external/event-loop/event-loop.rb |   26 
> +++++++++++++++-----------
>  1 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/puppet/external/event-loop/event-loop.rb 
> b/lib/puppet/external/event-loop/event-loop.rb
> index dc51a55..3b40f6e 100644
> --- a/lib/puppet/external/event-loop/event-loop.rb
> +++ b/lib/puppet/external/event-loop/event-loop.rb
> @@ -75,8 +75,10 @@ class EventLoop
>      @notify_src, @notify_snk = IO.pipe
>  
>      # prevent file descriptor leaks
> -    @notify_src.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
> -    @notify_snk.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
> +    if @notify_src.respond_to?(:fcntl) and defined?(Fcntl) and 
> defined?(Fcntl::F_SETFD) and defined?(Fcntl::FD_CLOEXEC)
> +      @notify_src.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
> +      @notify_snk.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
> +    end
>  
>      @notify_src.will_block = false
>      @notify_snk.will_block = false
> @@ -234,19 +236,21 @@ class IO
>    end
>  
>    def will_block?
> -    require "fcntl"
> -    fcntl(Fcntl::F_GETFL, 0) & Fcntl::O_NONBLOCK == 0
> +    if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) 
> and defined?(Fcntl::O_NONBLOCK)
> +      fcntl(Fcntl::F_GETFL, 0) & Fcntl::O_NONBLOCK == 0
> +    end
>    end
>  
>    def will_block= (wants_blocking)
> -    require "fcntl"
> -    flags = fcntl(Fcntl::F_GETFL, 0)
> -    if wants_blocking
> -      flags &= ~Fcntl::O_NONBLOCK
> -    else
> -      flags |= Fcntl::O_NONBLOCK
> +    if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) 
> and defined?(Fcntl::O_NONBLOCK)
> +      flags = fcntl(Fcntl::F_GETFL, 0)
> +      if wants_blocking
> +        flags &= ~Fcntl::O_NONBLOCK
> +      else
> +        flags |= Fcntl::O_NONBLOCK
> +      end
> +      fcntl(Fcntl::F_SETFL, flags)
>      end
> -    fcntl(Fcntl::F_SETFL, flags)
>    end
>  end
>  
> -- 
> 1.7.0.4
> 

Attachment: signature.asc
Description: Digital signature

Reply via email to