Conversation
In case of errors, the file descriptor is never closed. Fix it. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
There is no need to wait for up to 200ms in order to close the file descriptor once the chClose is received. This commit might reduce the chances for occasional "The process cannot access the file because it is being used by another process" error on Windows, where an opened file can't be removed. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
|
CI failures look unrelated, both are known flaky test suspects experimental:
power:
|
The code in Close() that removes the watches was not working,
because it first sets `w.closed = true` and then calls w.close(),
which starts with
```
if w.closed {
return errPollerClosed
}
```
Fix by setting w.closed only after calling w.remove() for all the
files being watched.
While at it, remove the duplicated `delete(w.watches, name)` code.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #37734 +/- ##
=========================================
Coverage ? 36.06%
=========================================
Files ? 609
Lines ? 45063
Branches ? 0
=========================================
Hits ? 16254
Misses ? 26582
Partials ? 2227 |
|
This bug was revealed because since #37412, this code is used for Windows logging |
Actually three (as depicted 😺) |
| for { | ||
| time.Sleep(watchWaitTime) | ||
| select { | ||
| case <-time.After(watchWaitTime): |
There was a problem hiding this comment.
You might have stray timers because of After, it's better to use NewTimer + Stop later I think.
There was a problem hiding this comment.
you mean Stop in defer ?
There was a problem hiding this comment.
Will the timer still finish? If yes, in here the watchWaitTime is 200ms and the watcher.Close() is not something called too often so if the timer will still finish I guess it's not big of an issue.
A couple of fixes to issues I found while reading the code. Might help reduce the number of mysterious bugs on Windows, where poller is used for logs. See individual commits for descriptions.