mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
winsftp.c: avoid creating multiple netevents.
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.
This commit is contained in:
@ -1026,10 +1026,10 @@ void cleanup_exit(int code)
|
||||
/*
|
||||
* Set up, or shut down, an AsyncSelect. Called from winnet.c.
|
||||
*/
|
||||
char *do_select(SOCKET skt, bool startup)
|
||||
char *do_select(SOCKET skt, bool enable)
|
||||
{
|
||||
int msg, events;
|
||||
if (startup) {
|
||||
if (enable) {
|
||||
msg = WM_NETEVENT;
|
||||
events = (FD_CONNECT | FD_READ | FD_WRITE |
|
||||
FD_OOB | FD_CLOSE | FD_ACCEPT);
|
||||
|
Reference in New Issue
Block a user