vendor/bundle/ruby/2.7.0/gems/dnsruby-1.61.5/lib/dnsruby/resolver.rb
#  This method is called twice a second from the select loop, in the select thread.
#  It should arguably be called from another worker thread... (which also handles the queue)
#  Each tick, we check if any timeouts have occurred. If so, we take the appropriate action :
#  Return a timeout to the client, or send a new query
This method is called twice a second from the select loop, in the select thread.
It should arguably be called from another worker thread... (which also handles the queue)
Each tick, we check if any timeouts have occurred. If so, we take the appropriate action :
Return a timeout to the client, or send a new query
This method is called twice a second from the select loop in the select thread . It should arguably be called from another worker thread ... ( which also handles the queue ) Each tick we check if any timeouts have occurred . If so we take the appropriate action : Return a timeout to the client or send a new query
def tick 
      @parent.single_res_mutex.synchronize {
        time_now = Time.now
        @timeouts.keys.each do |client_query_id|
          msg, client_queue, select_queue, outstanding = @query_list[client_query_id]
          query_timeout, timeouts = @timeouts[client_query_id]
          if query_timeout < Time.now
            send_result_and_stop_querying(client_queue, client_query_id, select_queue, nil,
                ResolvTimeout.new('Query timed out'))
            next
          end
          timeouts_done = []
          timeouts.keys.sort.each do |timeout|
            if timeout < time_now
              res, retry_count = timeouts[timeout]
              id = [res, msg, client_query_id, retry_count]
              Dnsruby.log.debug("Sending msg to #{res.server}")
              outstanding.push(id)
              timeouts_done.push(timeout)
              timeouts.delete(timeout)
              res.send_async(msg, select_queue, id)
            else
              break
            end
          end
          timeouts_done.each { |t| timeouts.delete(t) }
        end
      }
    end
def tick @parent . single_res_mutex . synchronize { time_now = Time . now @timeouts . keys . each do | client_query_id | msg , client_queue , select_queue , outstanding = @query_list [ client_query_id ] query_timeout , timeouts = @timeouts [ client_query_id ] if query_timeout < Time . now send_result_and_stop_querying ( client_queue , client_query_id , select_queue , nil , ResolvTimeout . new ( 'Query timed out' ) ) next end timeouts_done = [ ] timeouts . keys . sort . each do | timeout | if timeout < time_now res , retry_count = timeouts [ timeout ] id = [ res , msg , client_query_id , retry_count ] Dnsruby . log . debug ( "Sending msg to #{res.server}" ) outstanding . push ( id ) timeouts_done . push ( timeout ) timeouts . delete ( timeout ) res . send_async ( msg , select_queue , id ) else break end end timeouts_done . each { | t | timeouts . delete ( t ) } end } end
This method is called twice a second from the select loop, in the select thread.
This method is called twice a second from the select loop in the select thread .
# :nodoc: all #  Handle the tick #  Do we have any retries due to be sent yet? #       @mutex.synchronize{ #  Time the query out #  Send the next query #  We should keep a list of the queries which are outstanding #  Pick a new QID here @TODO@ !!! #               msg.header.id = rand(65535); #               print "New query : #{new_msg}\n"