go-clamd icon indicating copy to clipboard operation
go-clamd copied to clipboard

Goroutine leak

Open vboginskey opened this issue 6 years ago • 1 comments

The anonymous goroutine introduced in https://github.com/dutchcoders/go-clamd/pull/4/commits/4ca7e7b82651009473ab23a8a24bf7f5700f61bd will never exit unless the command is aborted. This leaks a goroutine per successful invocation of ScanStream.

vboginskey avatar Aug 21 '19 15:08 vboginskey

Good catch! I just looked at the code in which I used this library and I think I simply always called close on the abort channel.

Clearly this was way before context.Context became more commonly used, so my suggestion would be to rewrite it a little to use a context instead.

For what it's worth, I did use it in production extensively. So it is possible to use without goroutine leaks.

Freeaqingme avatar Aug 21 '19 16:08 Freeaqingme