Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions scanner/clamav.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package scanner

import (
clamd "github.com/dutchcoders/go-clamd"
"io"

clamd "github.com/dutchcoders/go-clamd"
)

/*
Expand Down Expand Up @@ -36,7 +37,9 @@ func (c *Clamav) Scan(reader io.Reader) (*Result, error) {
c.logger.Println("Sending to clamav")
}

ch, err := c.clam.ScanStream(reader, nil)
abortChannel := make(chan bool)
defer close(abortChannel) // necessary to not leak a goroutine. See https://github.com/dutchcoders/go-clamd/issues/9
ch, err := c.clam.ScanStream(reader, abortChannel)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -65,6 +68,11 @@ func (c *Clamav) Scan(reader io.Reader) (*Result, error) {
c.logger.Println(" result of scan:", result)
}

go func() {
for range ch {
} // empty the channel so the goroutine from go-clamd/*CLAMDConn.readResponse() doesn't get stuck
}()

return result, nil
}

Expand Down