Skip to content

Commit

Permalink
Add close statements to http calls to free up sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
ennui2342 committed May 21, 2012
1 parent 3a7b307 commit d2ce317
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/qswarm/speakers/http.rb
Expand Up @@ -37,23 +37,25 @@ def publish(format, msg)
http = EventMachine::HttpRequest.new(URI.join(@uri.to_s, msg)).get :head => head
end
http.errback do
logger.error "Error sending #{msg} to #{@name}: #{http.error}/#{http.response}"
logger.error "Error sending #{msg} to #{@name}: #{http.error}/#{http.response_header.status} #{http.response}"
end
http.callback do
http.callback do
if @args.expect != http.response_header.status
logger.error "#{@uri.to_s} Unexpected response code: #{http.response_header.status} #{http.response}"
end
http.close
end

when :post
http = EventMachine::HttpRequest.new(@uri).post :head => head, :body => msg
http.errback do
logger.error "Error sending #{msg} to #{@name}: #{http.error}/#{http.response_header.status} #{http.response}"
end
http.callback do
http.callback do
if @args.expect != http.response_header.status
logger.error "#{@uri.to_s} Unexpected response code: #{http.response_header.status} #{http.response}"
end
http.close
end
end
end
Expand Down

0 comments on commit d2ce317

Please sign in to comment.