sandeeprenjith / dnsblast

DNS Blast is a performance testing utility for DNS servers. It generates multiple simultaneous DNS queries against a specified DNS server and allows you to specify the rate of queries.
Other
36 stars 4 forks source link

Handle i/o timeout gracefully #8

Closed sandeeprenjith closed 4 years ago

sandeeprenjith commented 4 years ago

Timeout on DNS queries throws the below error

╭─nd33p@trv-wl-srenjith ~/go/src/github.com/sandeeprenjith/dnsblast ‹perf-improve*›
╰─$ go run main.go -l 10 -r 8000 -s 169.254.1.10 -t 1                                                                                                                                 1 ↵
2019/11/17 13:48:22 read udp 169.254.38.108:58280->169.254.1.10:53: i/o timeout
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x62b1aa]

goroutine 22 [running]:
github.com/sandeeprenjith/dnsblast/qry.SimpleQuery(0x7fffe8817de5, 0xc, 0x6a6dd8, 0x2, 0xc0000a62b0, 0xd, 0x6a6d95, 0x1, 0xc0000862a0)
        /home/nd33p/go/src/github.com/sandeeprenjith/dnsblast/qry/qry.go:29 +0x26a
main.send_qry(0x7fffe8817de5, 0xc, 0x1f40, 0x6a6dd8, 0x2, 0xa, 0x1, 0xc0000861e0, 0xc000084070)
        /home/nd33p/go/src/github.com/sandeeprenjith/dnsblast/main.go:52 +0xc8
created by main.main
        /home/nd33p/go/src/github.com/sandeeprenjith/dnsblast/main.go:123 +0x35b
exit status 2

Expected behavior IO Timeout should throw a more human readable and consise error and continue to further attempt queries

sandeeprenjith commented 4 years ago

Fixed with commit b28e6f6dee51efa516124a2000a9119db8957e58

$ go run main.go -s -r 200 -l 150
debug: Sleeping
2020/02/10 17:20:53 No usable results
2020/02/10 17:20:54 read tcp 192.168.130.9:50272->10.36.31.220:853: i/o timeout
2020/02/10 17:20:54 read tcp 192.168.130.9:50269->10.36.31.220:853: i/o timeout
2020/02/10 17:20:54 No usable results
2020/02/10 17:20:55 No usable results
2020/02/10 17:20:55 read tcp 192.168.130.9:50275->10.36.31.220:853: i/o timeout
2020/02/10 17:20:55 read tcp 192.168.130.9:50274->10.36.31.220:853: i/o timeout
2020/02/10 17:20:56 QPS:  2  Latency:  156.941ms
2020/02/10 17:20:57 read tcp 192.168.130.9:50276->10.36.31.220:853: i/o timeout
2020/02/10 17:20:57 No usable results
2020/02/10 17:20:58 QPS:  4  Latency:  228.062ms
^Csignal: interrupt