go-haproxy
go-haproxy copied to clipboard
Added deadline timeout for socket operations (avoid deadlocks)
Current implementation will be blocked forever in case if haproxy (or someone else, opened this socket) will not generate any answer and will not close socket.
So, the fix is:
- Presented new parameter TimeoutOp for operation timeout (separate from Timeout, used for connection timeout), now it will be possible to set Timeout = 10 (10 sec for connection) and TimeoutOp = 2 (2 sec for processing request).
- Added SetDeadline for connection
I tested with fake haproxy running by:
socat - UNIX-LISTEN:./var/run/haproxy.sock
Old implementation was blocked, new implementation returned after timeout:
read unix ->/var/run/haproxy.sock: i/o timeout