go-winio: Don't increment the wait count if the file is closing

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-07-19 17:50:55 +02:00
parent 7f786cf075
commit 4d14bfd8ad
No known key found for this signature in database
GPG Key ID: 40CF16616B361216

View File

@ -139,10 +139,10 @@ func (f *win32File) Close() error {
// prepareIo prepares for a new IO operation. // prepareIo prepares for a new IO operation.
// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning. // The caller must call f.wg.Done() when the IO is finished, prior to Close() returning.
func (f *win32File) prepareIo() (*ioOperation, error) { func (f *win32File) prepareIo() (*ioOperation, error) {
f.wg.Add(1)
if f.isClosing() { if f.isClosing() {
return nil, ErrFileClosed return nil, ErrFileClosed
} }
f.wg.Add(1)
c := &ioOperation{} c := &ioOperation{}
c.ch = make(chan ioResult) c.ch = make(chan ioResult)
return c, nil return c, nil