Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error conditions better #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions server/libs/dnser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ def serialize()
].pack("nnnnnn")

questions.each do |q|
result += q.serialize()
unless q.nil? then
result += q.serialize()
end
end

answers.each do |a|
Expand Down Expand Up @@ -841,6 +843,8 @@ def on_request()
@thread = Thread.new() do |t|
begin
loop do
goterror=false
begin
data = @s.recvfrom(65536)

# Data is an array where the first element is the actual data, and the second is the host/port
Expand All @@ -866,8 +870,13 @@ def on_request()
end
end
end
rescue Exception => e
puts("Caught an error: #{e}")
puts(e.backtrace())
goterror=true
end

if(!transaction.sent)
if(!goterror and !transaction.sent)
begin
proc.call(transaction)
rescue StandardError => e
Expand Down