mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Don't forget to read any outstanding data on receipt of FD_CLOSE.
Particularly useful for people speaking HTTP, Finger etc over raw connections. [originally from svn r913]
This commit is contained in:
parent
930fcdadeb
commit
ee154f7ed3
18
winnet.c
18
winnet.c
@ -560,7 +560,7 @@ void sk_write_oob(Socket s, char *buf, int len) {
|
||||
}
|
||||
|
||||
int select_result(WPARAM wParam, LPARAM lParam) {
|
||||
int ret;
|
||||
int ret, open;
|
||||
DWORD err;
|
||||
char buf[BUFFER_GRANULE];
|
||||
Socket s;
|
||||
@ -626,9 +626,19 @@ int select_result(WPARAM wParam, LPARAM lParam) {
|
||||
try_send(s);
|
||||
break;
|
||||
case FD_CLOSE:
|
||||
/* Signal a close on the socket. */
|
||||
return s->receiver(s, 0, NULL, 0);
|
||||
break;
|
||||
/* Signal a close on the socket. First read any outstanding data. */
|
||||
open = 1;
|
||||
do {
|
||||
ret = recv(s->s, buf, sizeof(buf), 0);
|
||||
if (ret < 0) {
|
||||
err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK)
|
||||
break;
|
||||
return s->receiver(s, 3, winsock_error_string(err), err);
|
||||
} else
|
||||
open &= s->receiver(s, 0, buf, ret);
|
||||
} while (ret > 0);
|
||||
return open;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user