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.
/*
* EOF, or (nearly equivalently) read error.
*/
/*
* EOF, or (nearly equivalently) read error.
*/
- h->u.i.gotdata(h, NULL, -h->u.i.readerr);
+ 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);
} else {
backlog = h->u.i.gotdata(h, h->u.i.buffer, h->u.i.len);
handle_throttle(&h->u.i, backlog);
* and mark the thread as defunct (because the output
* thread is terminating by now).
*/
* 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.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));
} else {
bufchain_consume(&h->u.o.queued_data, h->u.o.lenwritten);
h->u.o.sentdata(h, bufchain_size(&h->u.o.queued_data));