Project

General

Profile

Bug #11778

Updated by ko1 (Koichi Sasada) almost 9 years ago

Following test show the failure in the second recv_io call. 
 I was writing additional tests for FD passing when I noticed this. 

 I'm not sure if BasicSocket.for_fd should do with the mode flag if 
 we change its arity... 

 
 ~~~ 
 --- a/test/socket/test_unix.rb 
 +++ b/test/socket/test_unix.rb 
 @@ -37,6 +37,28 @@ def test_fd_passing 
      end 
    end 
 
 +    def test_fd_passing_class_mode 
 +      UNIXSocket.pair do |s1, s2| 
 +        s1.send_io(s1.fileno) 
 +        r = s2.recv_io(nil) 
 +        assert_kind_of Integer, r, 'recv_io with klass=nil returns integer FD' 
 +        assert_not_equal s1.fileno, r 
 +        r = IO.for_fd(r) 
 +        assert_equal s1.stat.ino, r.stat.ino 
 +        r.close 
 + 
 +        s1.send_io(s1) 
 +        klass = UNIXSocket 
 +        # OK with File or IO, fails with any BasicSocket subclass since 
 +        # BasicSocket.for_fd only takes one arg 
 +        # klass = File 
 +        r = s2.recv_io(klass, 'r+') 
 +        assert_instance_of klass, r, 'recv_io with proper klass' 
 +        assert_not_equal s1.fileno, r.fileno 
 +        r.close 
 +      end 
 +    end 
 + 
    def test_fd_passing_n 
      io_ary = [] 
      return if !defined?(Socket::SCM_RIGHTS) 
 ~~~ 

Back