lib/logstash/inputs/tcp.rb in logstash-input-tcp-3.0.1 vs lib/logstash/inputs/tcp.rb in logstash-input-tcp-3.0.2

- old
+ new

@@ -113,11 +113,10 @@ # start a new thread for each connection. server_connection_thread(output_queue, socket) rescue OpenSSL::SSL::SSLError => e # log error, close socket, accept next connection @logger.error("SSL Error", :exception => e, :backtrace => e.backtrace) - socket.close rescue nil rescue => e # if this exception occured while the plugin is stopping # just ignore and exit raise e unless stop? end @@ -147,29 +146,30 @@ end end end def handle_socket(socket, client_address, client_port, output_queue, codec) + peer = "#{client_address}:#{client_port}" while !stop? codec.decode(read(socket)) do |event| event["host"] ||= client_address event["port"] ||= client_port event["sslsubject"] ||= socket.peer_cert.subject.to_s if @ssl_enable && @ssl_verify decorate(event) output_queue << event end end rescue EOFError - @logger.debug? && @logger.debug("Connection closed", :client => socket.peer) + @logger.debug? && @logger.debug("Connection closed", :client => peer) rescue Errno::ECONNRESET - @logger.debug? && @logger.debug("Connection reset by peer", :client => socket.peer) + @logger.debug? && @logger.debug("Connection reset by peer", :client => peer) rescue OpenSSL::SSL::SSLError => e # Fixes issue #23 @logger.error("SSL Error", :exception => e, :backtrace => e.backtrace) socket.close rescue nil rescue => e # if plugin is stopping, don't bother logging it as an error - !stop? && @logger.error("An error occurred. Closing connection", :client => socket.peer, :exception => e, :backtrace => e.backtrace) + !stop? && @logger.error("An error occurred. Closing connection", :client => peer, :exception => e, :backtrace => e.backtrace) ensure # catch all rescue nil on close to discard any close errors or invalid socket socket.close rescue nil codec.respond_to?(:flush) && codec.flush do |event|