On Tue, May 7, 2013 at 3:14 AM, Hans Leidekker hans@codeweavers.com wrote:
... TerminateThread is not the right tool here. If the thread is blocked on the recv call while being terminated it will leak the netlink socket.
You'd need a way to synchronize the threads, but an overhead of one thread per caller is rather costly in the first place. This suggests that the server should poll the socket.
So far the iphlpapi hasn't been doing anything directly with the server... How about launching a single thread for NotifyAddrChange (when needed) and keeping a list of OVERLAPPED structures to signal when the list changes? It's easy enough to use MSG_DONTWAIT to make recv non-blocking so that it's easy to cancel the thread.
Best, Erich