Project

General

Profile

Actions

Bug #5845

closed

Addrinfo#connect_from が Addrinfo オブジェクトを受け付けない

Added by ohai (Ippei Obayashi) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-01-04 trunk 34210) [x86_64-linux]
Backport:
[ruby-dev:45095]

Description

Addrinfo#connect_from (ext/socket/lib/socket.rb) の rdoc には

# Addrinfo object can be taken for the argument.

Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s|

s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"

puts s.read

}

とあり、 Addrinfo オブジェクトを受け付けるように書かれていますが、実際には
その内容は無視されてしまいます。以下のようなスクリプトで確認できます。
require 'socket'
Addrinfo.tcp("www.example.com", 80).connect_from(Addrinfo.tcp("0.0.0.0", 49021)) {|s|
p s.local_address.ip_port
s.close
}
原因は Addrinfo#family_addrinfo に Addrinfo オブジェクトを渡した時の返り値が適切でないことです。
添付したパッチでとりあえずは期待通りに動きます。

適当に作った問題再現用テストも添付します。


Files

addrinfo_family_addrinfo_fix.patch (722 Bytes) addrinfo_family_addrinfo_fix.patch ohai (Ippei Obayashi), 01/05/2012 06:35 PM
addrinfo_connect_from_test.patch (836 Bytes) addrinfo_connect_from_test.patch ohai (Ippei Obayashi), 01/05/2012 06:35 PM
Actions #1

Updated by akr (Akira Tanaka) about 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34244.
Ippei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/socket/lib/socket.rb (family_addrinfo): return the given
    addrinfo object.
    Patch by Ippei Obayashi. [ruby-dev:45095] [Bug #5845]
Actions

Also available in: Atom PDF

Like0
Like0