File: fd.ruby

package info (click to toggle)
dnsruby 1.73.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,548 kB
  • sloc: ruby: 17,966; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby

# frozen_string_literal: true

require 'dnsruby'
require 'thread'

#Dnsruby.log.level = Logger::DEBUG

# speed up the repro
NFILES = 30
nfiles, _ = Process.getrlimit(Process::RLIMIT_NOFILE)
Process.setrlimit(Process::RLIMIT_NOFILE, NFILES) if nfiles > NFILES

NAMESERVERS = ["192.31.80.30"]

Thread.new {
  res = Dnsruby::Resolver.new(nameserver: NAMESERVERS, do_caching: false, query_timeout: 5)
  loop do
    begin
      res.query("blahblahblah.com.edgekey.net", "CNAME")
    rescue Dnsruby::ResolvError
    end
    sleep 0.2
  end
}

loop do
#  system("ls -l /proc/#{Process.pid}/fd/")
  system("lsof -p #{Process.pid} | wc -l")
  File.open("/") { |_| }
  sleep 1
end