mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-18 03:28:07 -05:00

The do_select function is called with a boolean parameter indicating whether we're supposed to start or stop paying attention to network activity on a given socket. So if we freeze and unfreeze the socket in mid-session because of backlog, we'll call do_select(s, false) to freeze it, and do_select(s, true) to unfreeze it. But the implementation of do_select in the Windows SFTP code predated the rigorous handling of socket backlogs, so it assumed that do_select(s, true) would only be called at initialisation time, i.e. only once, and therefore that it was safe to use that flag as a cue to set up the Windows event object to associate with socket activity. Hence, every time the socket was frozen and unfrozen, we would create a new netevent at unfreeze time, leaking the old one. I think perhaps part of the reason why that was hard to figure out was that the boolean parameter was called 'startup' rather than 'enable'. To make it less confusing the next time I read this code, I've also renamed it, and while I was at it, adjusted another related comment. (cherry picked from commit bd5c957e5bd0f850ab30c6b1ab94bfbbabe9f006)