The code for cleaning up handle structures works by the main thread
asking the per-handle subthread to shut down by means of setting its
'done' flag, and then once the subthread signals back through its
event object that it's done so, the main thread frees all its
resources and removes the event object from the list of things being
checked in the program's event loop.
But read threads were not sending back that final event acknowledging
a request to shut down, so their event objects were never being
cleaned up.
Bug spotted by Ronald Weiss.
break;
WaitForSingleObject(ctx->ev_from_main, INFINITE);
- if (ctx->done)
+ if (ctx->done) {
+ SetEvent(ctx->ev_to_main);
break; /* main thread told us to shut down */
+ }
}
if (povl)