logstash-plugins / logstash-input-syslog

Apache License 2.0
37 stars 38 forks source link

Change TCP reading mode to use the non-blocking method #75

Closed edmocosta closed 11 months ago

edmocosta commented 12 months ago

The plugin is not properly detecting client disconnections. It seems it keeps trying to read from closed sockets, making the CPU usage grow every time a client disconnects or send EOF.

The problem is happening on the socket.each method. When the client connection is closed, or it receives an EOF, the code expects it to raise an error (EOFError, ...), stopping the loop, closing the connection and removing it from the connection counter. Instead, it doesn't raise any error, and the CPU usage grows due to some internal issue.

The alternative solution is to change it to read using a non-blocking approach. The read_nonblock raises EOF/disconnect errors, making the existing code work properly.

This PR:


Closes: https://github.com/logstash-plugins/logstash-input-syslog/issues/74 Closes: https://github.com/logstash-plugins/logstash-input-syslog/issues/70