Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lfs/gitscanner_catfilebatchcheck.go: close channel
In commit 08c5ae6 of PR #1953 the runCatFileBatchCheck() and runCatFileBatch() functions of the "lfs" package were updated to write the pathspecs of locked files which are not Git LFS pointers to a dedicated channel created by the catFileBatchCheck() and catFileBatch() wrapper functions, respectively. The scanRefsToChan() function, which calls both of these with a potentially non-nil *lockableNameSet paramter (and is the only caller to do so), starts a goroutine with an anonymous function to read any events on the channel returned by catFileBatchCheck(), and then reads all events on the channel returned by catFileBatch() directly. In the latter case, this would cause scanRefsToChan() to stall indefinitely unless the channel is closed, so the anonymous function started by the runCatFileBatch() function that writes to the channel always closes the channel upon exit. However, the anonymous function started by the runCatFileBatchCheck() function that writes to its lock path channel does not do the same. While this does not cause a stalled program because scanRefsToChan() creates its own anonymous function to read from the channel, that function will not exit until the progam stops. By adding an explicit close() of the channel at the end of the anonymous function started by runCatFileBatchCheck(), we can ensure the anonymous function which reads that channel will also exit as soon as possible.
- Loading branch information