Closed bflyblue closed 4 years ago
In the case where a sock is created but unable to connect, the socket is not closed and is leaked in the following line:
sock
connect
https://github.com/informatikr/hedis/blob/eb62c5d4b40822e5f9724918150f6105359dca24/src/Database/Redis/ProtocolPipelining.hs#L98
On my system the IPv6 address is tried first and fails before the IPv4 address connects, resulting in many un-closed sockets until the process runs out of file descriptors, as seen in lsof:
lsof
meerkat 5238 root 40u sock 0,9 0t0 654985 protocol: TCPv6 meerkat 5238 root 41u sock 0,9 0t0 661617 protocol: TCPv6 ... meerkat 5238 root 743u sock 0,9 0t0 693816 protocol: TCPv6
As a quick test I changed line 98 to the following and can confirm it fixes my issue:
Left err -> NS.close sock >> return (Left err)
Looks like bracketOnError doesn't trigger because we use try inside. Anyway I made a PR
bracketOnError
try
Thanks! Uploaded as 0.12.13
In the case where a
sock
is created but unable toconnect
, the socket is not closed and is leaked in the following line:https://github.com/informatikr/hedis/blob/eb62c5d4b40822e5f9724918150f6105359dca24/src/Database/Redis/ProtocolPipelining.hs#L98
On my system the IPv6 address is tried first and fails before the IPv4 address connects, resulting in many un-closed sockets until the process runs out of file descriptors, as seen in
lsof
:As a quick test I changed line 98 to the following and can confirm it fixes my issue: