mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-16 12:03:03 -05:00
Forcibly close any TCP connections that are still open when PuTTY exits.
This saves leaving them lying around to crash the machine later. [originally from svn r2524]
This commit is contained in:
parent
34a96d4924
commit
c342678579
@ -233,7 +233,24 @@ OSErr mactcp_init(void)
|
|||||||
|
|
||||||
void mactcp_shutdown(void)
|
void mactcp_shutdown(void)
|
||||||
{
|
{
|
||||||
|
Actual_Socket s, next;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Eventually, PuTTY should close down each session as it exits,
|
||||||
|
* so there should be no sockets left when we get here. Still,
|
||||||
|
* better safe than sorry.
|
||||||
|
*
|
||||||
|
* XXX What about in-flight aync I/O (when we support that)?
|
||||||
|
*/
|
||||||
|
for (s = mactcp.socklist; s != NULL; s = next) {
|
||||||
|
next = s->next; /* s is about to vanish */
|
||||||
|
mactcp_close(&s->fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When we get async DNS, we have to wait for any outstanding
|
||||||
|
* requests to complete here before exiting.
|
||||||
|
*/
|
||||||
CloseResolver();
|
CloseResolver();
|
||||||
mactcp.initialised = FALSE;
|
mactcp.initialised = FALSE;
|
||||||
}
|
}
|
||||||
@ -574,16 +591,21 @@ void mactcp_poll(void)
|
|||||||
|
|
||||||
for (s = mactcp.socklist; s != NULL; s = s->next) {
|
for (s = mactcp.socklist; s != NULL; s = s->next) {
|
||||||
/* XXX above can't handle sockets being deleted. */
|
/* XXX above can't handle sockets being deleted. */
|
||||||
|
do {
|
||||||
pb.ioCRefNum = mactcp.refnum;
|
pb.ioCRefNum = mactcp.refnum;
|
||||||
pb.csCode = TCPStatus;
|
pb.csCode = TCPStatus;
|
||||||
pb.tcpStream = s->s;
|
pb.tcpStream = s->s;
|
||||||
pb.csParam.status.userDataPtr = (Ptr)s;
|
pb.csParam.status.userDataPtr = (Ptr)s;
|
||||||
s->err = PBControlSync((ParmBlkPtr)&pb);
|
s->err = PBControlSync((ParmBlkPtr)&pb);
|
||||||
if (s->err != noErr)
|
if (s->err != noErr)
|
||||||
continue;
|
goto next_socket;
|
||||||
if (pb.csParam.status.amtUnreadData > 0)
|
if (pb.csParam.status.amtUnreadData == 0)
|
||||||
|
break;
|
||||||
mactcp_recv(s, pb.csParam.status.amtUnreadData);
|
mactcp_recv(s, pb.csParam.status.amtUnreadData);
|
||||||
/* Should check connectionState in case remote has closed */
|
/* Should check connectionState in case remote has closed */
|
||||||
|
} while (TRUE);
|
||||||
|
next_socket:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user