]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Mark handles defunct before calling gotdata/sentdata.
authorSimon Tatham <anakin@pobox.com>
Sat, 7 Feb 2015 12:39:47 +0000 (12:39 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 7 Feb 2015 12:50:08 +0000 (12:50 +0000)
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.

windows/winhandl.c

index 193f24d76a6d529367fdfa57682e7441cb3dcc49..6b129ad886591c4fb9d5dd73c9935ede24089b9f 100644 (file)
@@ -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));