Skip to content
Permalink
Browse files
change IO.setup to set fd accessor; fixes socket setup
I don't really like this solution very much. Ideally the
Socket classes would set @fd directly in their #initialize
methods via a call to FileDescriptor.choose_type(fd). Having
a +fd+ accessor on the IO class was intended only for
debugging purposes.

Let's go with this patch for now. If the larger refactoring
of the IO class to use a private IO::FileDescriptor class
is accepted then we can go back and change the Socket methods
to conform better and remove this accessor.
  • Loading branch information
chuckremes committed Jan 21, 2016
1 parent 23ade65 commit 685a4a5236de52b8dc8282135fa8baa8eee4a573
Showing with 4 additions and 2 deletions.
  1. +4 −2 kernel/common/io.rb
@@ -962,7 +962,8 @@ def self.validate_and_convert_argument(objects)

attr_accessor :external
attr_accessor :internal
attr_accessor :fd # FIXME: just for debugging
# intended to only be used by IO.setup to associate a new FileDescriptor object with instance of IO
attr_accessor :fd

def self.binread(file, length=nil, offset=0)
raise ArgumentError, "Negative length #{length} given" if !length.nil? && length < 0
@@ -1625,7 +1626,8 @@ def self.setup(io, fd, mode=nil, sync=false)
end
end

#io.descriptor = fd
fd_obj = FileDescriptor.choose_type(fd)
io.fd = fd_obj
io.mode = mode || cur_mode
io.sync = !!sync

0 comments on commit 685a4a5

Please sign in to comment.