From: Joseph Jones Date: 2015-12-17T21:06:11-07:00 Subject: [ruby-core:72260] [Ruby trunk - Bug #11778] [Open] recv_io with mode breaks when klass arg is kind of BasicSocket --56738633_75a2a8d4_16c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Joseph Jones liked your message with Boxer. On December 6, 2015 at 07:27:= 50 MST, normalperson=40yhbt.net wrote:Issue =2311778 has been reported by= Eric Wong.----------------------------------------Bug =2311778: recv=5Fi= o with mode breaks when klass arg is kind of BasicSockethttps://bugs.ruby= -lang.org/issues/11778* Author: Eric Wong* Status: Open* Priority: Normal= * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNK= NOWN----------------------------------------=46ollowing test show the fai= lure in the second recv=5Fio call.I was writing additional tests for =46D= passing when I noticed this.I'm not sure if BasicSocket.for=5Ffd should = do with the mode flag ifwe change its arity...=7E=7E=7E--- a/test/socket/= test=5Funix.rb+++ b/test/socket/test=5Funix.rb=40=40 -37,6 +37,28 =40=40 = def test=5Ffd=5Fpassing end end + def test=5Ffd=5Fpassing=5Fclass=5Fmode+= UNIXSocket.pair do =7Cs1, s2=7C+ s1.send=5Fio(s1.fileno)+ r =3D s2.recv=5F= io(nil)+ assert=5Fkind=5Fof Integer, r, 'recv=5Fio with klass=3Dnil retur= ns integer =46D'+ assert=5Fnot=5Fequal s1.fileno, r+ r =3D IO.for=5Ffd(r)= + assert=5Fequal s1.stat.ino, r.stat.ino+ r.close++ s1.send=5Fio(s1)+ kla= ss =3D UNIXSocket+ =23 OK with =46ile or IO, fails with any BasicSocket s= ubclass since+ =23 BasicSocket.for=5Ffd only takes one arg+ =23 klass =3D= =46ile+ r =3D s2.recv=5Fio(klass, 'r+')+ assert=5Finstance=5Fof klass, r= , 'recv=5Fio with proper klass'+ assert=5Fnot=5Fequal s1.fileno, r.fileno= + r.close+ end+ end+ def test=5Ffd=5Fpassing=5Fn io=5Fary =3D =5B=5D retu= rn if =21defined=3F(Socket::SCM=5FRIGHTS)=7E=7E=7E-- https://bugs.ruby-la= ng.org/ --56738633_75a2a8d4_16c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Joseph Jones liked your message with Boxer.


= On December 6, 2015 at 07:27:50 MST, normalperson=40yhbt.net wrote:
<= blockquote type=3D=22cite=22 style=3D=22border-left-style:solid;border-wi= dth:1px;margin-left:0px;padding-left:10px;=22>Issue =2311778 has been rep= orted by Eric Wong.

----------------------------------------Bug =2311778: recv=5Fio with mode breaks when klass arg is kind of Ba= sicSocket
https://bugs.ruby-lang.org/issues/11778

* Autho= r: Eric Wong
* Status: Open
* Priority: Normal
* Assignee:=
* ruby -v:
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UN= KNOWN
----------------------------------------
=46ollowing test= show the failure in the second recv=5Fio call.
I was writing additi= onal tests for =46D passing when I noticed this.

I'm not sure = if BasicSocket.for=5Ffd should do with the mode flag if
we change it= s arity...
=7E=7E=7E
--- a/test/socket/test=5Funix.rb
+++ = b/test/socket/test=5Funix.rb
=40=40 -37,6 +37,28 =40=40 def test=5Ff= d=5Fpassing
end
end

+ def test=5Ffd=5Fpass= ing=5Fclass=5Fmode
+ UNIXSocket.pair do =7Cs1, s2=7C
+ = s1.send=5Fio(s1.fileno)
+ r =3D s2.recv=5Fio(nil)
+ a= ssert=5Fkind=5Fof Integer, r, 'recv=5Fio with klass=3Dnil returns integer= =46D'
+ assert=5Fnot=5Fequal s1.fileno, r
+ r =3D IO= .for=5Ffd(r)
+ assert=5Fequal s1.stat.ino, r.stat.ino
+ = r.close
+
+ s1.send=5Fio(s1)
+ klass =3D UNIX= Socket
+ =23 OK with =46ile or IO, fails with any BasicSocket s= ubclass since
+ =23 BasicSocket.for=5Ffd only takes one arg
+ =23 klass =3D =46ile
+ r =3D s2.recv=5Fio(klass, 'r+')=
+ assert=5Finstance=5Fof klass, r, 'recv=5Fio with proper klas= s'
+ assert=5Fnot=5Fequal s1.fileno, r.fileno
+ r.clo= se
+ end
+ end
+
def test=5Ffd=5Fpassing=5Fn io=5Fary =3D =5B=5D
return if =21defined=3F(Socket::SC= M=5FRIGHTS)
=7E=7E=7E




--
https://= bugs.ruby-lang.org/
--56738633_75a2a8d4_16c--