[ruby-core:88665] [Ruby trunk Bug#13593] Addrinfo#== behaves oddly

From: shyouhei@...
Date: 2018-08-27 04:41:17 UTC
List: ruby-core #88665
Issue #13593 has been updated by shyouhei (Shyouhei Urabe).


ioquatix (Samuel Williams) wrote:
> Doing a binary comparison would be acceptable.

I don't think so.  As Akira already pointed out,

- Addrinfo have "padding" bits which are not stable.  Binary comparison might fail at that point.
- Addrinfo can handle arbitrary socket addresses, not only internet things.  Which makes it impossible to tell which bit is a padding and which is not.

----------------------------------------
Bug #13593: Addrinfo#== behaves oddly
https://bugs.ruby-lang.org/issues/13593#change-73722

* Author: ioquatix (Samuel Williams)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
It appears as if Addrinfo is using object identity. `Addrinfo#==` doesn't appear to work as one might expect, given the same instantiation:

~~~
> irb
2.4.0 :001 > require 'socket'
 => true 
2.4.0 :002 > Addrinfo.tcp('0.0.0.0', 1234) == Addrinfo.tcp('0.0.0.0', 1234)
 => false 
2.4.0 :003 > a = Addrinfo.tcp('0.0.0.0', 1234)
 => #<Addrinfo: 0.0.0.0:1234 TCP> 
2.4.0 :004 > a == a
 => true 
2.4.0 :005 > 
~~~



---Files--------------------------------
addrinfo_eql.diff (575 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next