lib/statsd.rb in statsd-client-0.0.2 vs lib/statsd.rb in statsd-client-0.0.3
- old
+ new
@@ -1,10 +1,10 @@
require 'socket'
class Statsd
- Version = '0.0.2'
+ Version = '0.0.3'
class << self
attr_accessor :host, :port
@@ -48,12 +48,17 @@
return if data.empty?
raise "host and port must be set" unless host && port
- sock = UDPSocket.new
- data.each do |d|
- sock.send(d, 0, host, port)
+ begin
+ sock = UDPSocket.new
+ data.each do |d|
+ sock.send(d, 0, host, port)
+ end
+ rescue # silent but deadly
+ ensure
+ sock.close
end
true
end
\ No newline at end of file