Skip to content

Commit

Permalink
change IO.setup to set fd accessor; fixes socket setup
Browse files Browse the repository at this point in the history
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 685a4a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/common/io.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 685a4a5

Please sign in to comment.