diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-08 03:19:53 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-03-08 03:19:53 +0000 |
commit | 003d0aecc30a939f0712d9f85e2c150e8ccb78da (patch) | |
tree | 58942c932f7fb0100840d629833f0daf0fda3621 /lib | |
parent | ee36f57775c0d8715aa73486ee47b54c11cf920e (diff) | |
download | ruby-003d0aecc30a939f0712d9f85e2c150e8ccb78da.tar.gz ruby-003d0aecc30a939f0712d9f85e2c150e8ccb78da.tar.xz ruby-003d0aecc30a939f0712d9f85e2c150e8ccb78da.zip |
* lib/resolv.rb: use its own thread group for background threads.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/resolv.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb index bfe8dd8b6..d1b7c3c9f 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -341,6 +341,8 @@ class Resolv Port = 53 UDPSize = 512 + DNSThreadGroup = ThreadGroup.new + def initialize(config="/etc/resolv.conf") @mutex = Mutex.new @config = Config.new(config) @@ -512,6 +514,7 @@ class Resolv @id = {} @id.default = -1 @thread = Thread.new { + DNSThreadGroup.add Thread.current loop { reply, from = @sock.recvfrom(UDPSize) msg = begin @@ -565,6 +568,7 @@ class Resolv @sock.fcntl(Fcntl::F_SETFD, 1) @id = -1 @thread = Thread.new { + DNSThreadGroup.add Thread.current loop { reply = @sock.recv(UDPSize) msg = begin @@ -616,6 +620,7 @@ class Resolv @id = -1 @senders = {} @thread = Thread.new { + DNSThreadGroup.add Thread.current loop { len = @sock.read(2).unpack('n') reply = @sock.read(len) |