mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-27 02:02:26 +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
16
winnet.c
16
winnet.c
@ -560,7 +560,7 @@ void sk_write_oob(Socket s, char *buf, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int select_result(WPARAM wParam, LPARAM lParam) {
|
int select_result(WPARAM wParam, LPARAM lParam) {
|
||||||
int ret;
|
int ret, open;
|
||||||
DWORD err;
|
DWORD err;
|
||||||
char buf[BUFFER_GRANULE];
|
char buf[BUFFER_GRANULE];
|
||||||
Socket s;
|
Socket s;
|
||||||
@ -626,9 +626,19 @@ int select_result(WPARAM wParam, LPARAM lParam) {
|
|||||||
try_send(s);
|
try_send(s);
|
||||||
break;
|
break;
|
||||||
case FD_CLOSE:
|
case FD_CLOSE:
|
||||||
/* Signal a close on the socket. */
|
/* Signal a close on the socket. First read any outstanding data. */
|
||||||
return s->receiver(s, 0, NULL, 0);
|
open = 1;
|
||||||
|
do {
|
||||||
|
ret = recv(s->s, buf, sizeof(buf), 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
err = WSAGetLastError();
|
||||||
|
if (err == WSAEWOULDBLOCK)
|
||||||
break;
|
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;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user