1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/resolv.rb: use its own thread group for background threads.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2002-03-08 03:19:53 +00:00
parent effd8230ea
commit d41f53d0b6
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Fri Mar 8 12:19:15 2002 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb: use its own thread group for background threads.
Thu Mar 7 20:08:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> Thu Mar 7 20:08:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* gc.c (rb_source_filename): added. holds unique strings for file * gc.c (rb_source_filename): added. holds unique strings for file
@ -66,7 +70,7 @@ Fri Mar 1 06:25:49 2002 Tanaka Akira <akr@m17n.org>
check msg_control and msg_accrights in struct msghdr. check check msg_control and msg_accrights in struct msghdr. check
sys/uio.h. sys/uio.h.
* socket/socket.c: include sys/uio.h if available. * ext/socket/socket.c: include sys/uio.h if available.
(thread_read_select): new function. (thread_read_select): new function.
(unix_send_io): ditto. (unix_send_io): ditto.
(unix_recv_io): ditto. (unix_recv_io): ditto.

View file

@ -341,6 +341,8 @@ class Resolv
Port = 53 Port = 53
UDPSize = 512 UDPSize = 512
DNSThreadGroup = ThreadGroup.new
def initialize(config="/etc/resolv.conf") def initialize(config="/etc/resolv.conf")
@mutex = Mutex.new @mutex = Mutex.new
@config = Config.new(config) @config = Config.new(config)
@ -512,6 +514,7 @@ class Resolv
@id = {} @id = {}
@id.default = -1 @id.default = -1
@thread = Thread.new { @thread = Thread.new {
DNSThreadGroup.add Thread.current
loop { loop {
reply, from = @sock.recvfrom(UDPSize) reply, from = @sock.recvfrom(UDPSize)
msg = begin msg = begin
@ -565,6 +568,7 @@ class Resolv
@sock.fcntl(Fcntl::F_SETFD, 1) @sock.fcntl(Fcntl::F_SETFD, 1)
@id = -1 @id = -1
@thread = Thread.new { @thread = Thread.new {
DNSThreadGroup.add Thread.current
loop { loop {
reply = @sock.recv(UDPSize) reply = @sock.recv(UDPSize)
msg = begin msg = begin
@ -616,6 +620,7 @@ class Resolv
@id = -1 @id = -1
@senders = {} @senders = {}
@thread = Thread.new { @thread = Thread.new {
DNSThreadGroup.add Thread.current
loop { loop {
len = @sock.read(2).unpack('n') len = @sock.read(2).unpack('n')
reply = @sock.read(len) reply = @sock.read(len)