Allow to abort scanning a stream prematurely
This commit is contained in:
12
clamd.go
12
clamd.go
@@ -258,12 +258,22 @@ the actual chunk. Streaming is terminated by sending a zero-length chunk. Note:
|
|||||||
do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will
|
do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will
|
||||||
reply with INSTREAM size limit exceeded and close the connection
|
reply with INSTREAM size limit exceeded and close the connection
|
||||||
*/
|
*/
|
||||||
func (c *Clamd) ScanStream(r io.Reader) (chan *ScanResult, error) {
|
func (c *Clamd) ScanStream(r io.Reader, abort chan bool) (chan *ScanResult, error) {
|
||||||
conn, err := c.newConnection()
|
conn, err := c.newConnection()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
_, allowRunning := <-abort
|
||||||
|
if !allowRunning {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
conn.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
conn.sendCommand("INSTREAM")
|
conn.sendCommand("INSTREAM")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|||||||
Reference in New Issue
Block a user