From: Simon Tatham Date: Sat, 7 Feb 2015 12:39:47 +0000 (+0000) Subject: Mark handles defunct before calling gotdata/sentdata. X-Git-Tag: 0.64~6 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=087ca595f3f612f0d2de1d406b5fcc751cdd3566;hp=-c;p=PuTTY.git Mark handles defunct before calling gotdata/sentdata. If (say) a read handle returns EOF, and its gotdata function responds by calling handle_free(), then we want the handle to have already had its defunct flag set so that the handle can be destroyed. Otherwise handle_free will set the 'done' flag to ask the subthread to terminate, and then sit and wait for it to say it's done so - forgetting that it signalled termination already by returning EOF, and hence will not be responding to that signal. Ditto for write errors on write handles, though that should happen less often. --- 087ca595f3f612f0d2de1d406b5fcc751cdd3566 diff --git a/windows/winhandl.c b/windows/winhandl.c index 193f24d7..6b129ad8 100644 --- a/windows/winhandl.c +++ b/windows/winhandl.c @@ -629,8 +629,8 @@ void handle_got_event(HANDLE event) /* * EOF, or (nearly equivalently) read error. */ - h->u.i.gotdata(h, NULL, -h->u.i.readerr); h->u.i.defunct = TRUE; + h->u.i.gotdata(h, NULL, -h->u.i.readerr); } else { backlog = h->u.i.gotdata(h, h->u.i.buffer, h->u.i.len); handle_throttle(&h->u.i, backlog); @@ -651,8 +651,8 @@ void handle_got_event(HANDLE event) * and mark the thread as defunct (because the output * thread is terminating by now). */ - h->u.o.sentdata(h, -h->u.o.writeerr); h->u.o.defunct = TRUE; + h->u.o.sentdata(h, -h->u.o.writeerr); } else { bufchain_consume(&h->u.o.queued_data, h->u.o.lenwritten); h->u.o.sentdata(h, bufchain_size(&h->u.o.queued_data));