From 0d9c7d82e8506d9b6da557cfaf8a08bc3bfeb299 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 4 Jun 2016 15:42:06 +0100 Subject: [PATCH] Don't treat plug_closing() and plug_receive() as returning backlog. plug_receive() and plug_closing() return 0 or 1 depending on whether they think the main connection has closed. It is not appropriate, as handle_gotdata and handle_socket_unfreeze did, to treat them as returning a backlog. In fact, plugs are unusual in PuTTY in not reporting a backlog, but just calling into the socket to freeze and unfreeze it as required. --- windows/winhsock.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/windows/winhsock.c b/windows/winhsock.c index c8cb46f6..799fd28d 100644 --- a/windows/winhsock.c +++ b/windows/winhsock.c @@ -54,10 +54,11 @@ static int handle_gotdata(struct handle *h, void *data, int len) Handle_Socket ps = (Handle_Socket) handle_get_privdata(h); if (len < 0) { - return plug_closing(ps->plug, "Read error from handle", - 0, 0); + plug_closing(ps->plug, "Read error from handle", 0, 0); + return 0; } else if (len == 0) { - return plug_closing(ps->plug, NULL, 0, 0); + plug_closing(ps->plug, NULL, 0, 0); + return 0; } else { assert(ps->frozen != FROZEN && ps->frozen != THAWING); if (ps->frozen == FREEZING) { @@ -76,7 +77,8 @@ static int handle_gotdata(struct handle *h, void *data, int len) */ return INT_MAX; } else { - return plug_receive(ps->plug, 0, data, len); + plug_receive(ps->plug, 0, data, len); + return 0; } } } @@ -168,7 +170,7 @@ static void handle_socket_unfreeze(void *psv) { Handle_Socket ps = (Handle_Socket) psv; void *data; - int len, new_backlog; + int len; /* * If we've been put into a state other than THAWING since the @@ -188,7 +190,7 @@ static void handle_socket_unfreeze(void *psv) * have the effect of trying to close this socket. */ ps->defer_close = TRUE; - new_backlog = plug_receive(ps->plug, 0, data, len); + plug_receive(ps->plug, 0, data, len); bufchain_consume(&ps->inputdata, len); ps->defer_close = FALSE; if (ps->deferred_close) { @@ -207,7 +209,7 @@ static void handle_socket_unfreeze(void *psv) * Otherwise, we've successfully thawed! */ ps->frozen = UNFROZEN; - handle_unthrottle(ps->recv_h, new_backlog); + handle_unthrottle(ps->recv_h, 0); } }