Skip to content

Commit

Permalink
Better error handling and cleanup.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/ControlTower/trunk@4282 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
jballanc committed Jun 25, 2010
1 parent 561711c commit e8e965c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/control_tower/rack_socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ def open
response_data.each do |chunk|
connection.write chunk
end
else
$stderr.puts "Error: No request data receieved!"
end
rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL, Errno::EBADF
connection.close rescue nil
rescue Errno::EMFILE
# TODO: Need to do something about the dispatch queue...a group wait, maybe? or a dispatch semaphore?
rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL
$stderr.puts "Error: Connection terminated!"
rescue Object => e
$stderr.puts "Error receiving data: #{e.inspect}"
$stderr.puts "Error: Problem transmitting data -- #{e.inspect}"
ensure
# TODO: Keep-Alive might be nice, but not yet
# We should clean up after our tempfile, if we used one.
unlink env['rack.input'] if env['rack.input'].class == Tempfile
connection.close rescue nil
end
end
Expand Down

0 comments on commit e8e965c

Please sign in to comment.