On 4 November 2018 at 22:03, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 02/11/2018 14:33, Peter Maydell wrote: >> On 9 October 2018 at 12:16, Paolo Bonzini <pbonz...@redhat.com> wrote: >>> Yup, we have to stop using pthread_key_create. Luckily, these days >>> there is always qemu_thread_start that wraps the thread, so we can call >>> qemu_thread_atexit_run from there, and change exit_key to a thread-local >>> NotifierList. >> >> We would also need to catch exits via qemu_thread_exit(), right? >> We probably also need to handle the main thread specially, via >> atexit(). This seems to be pretty much what we already do in >> util/qemu-thread-win32.c... > > There's only one caller of qemu_thread_exit and it can be removed easily. > > However, an improvement on the idea is to use pthread_cleanup_push/pop > in qemu_thread_start. This does handle qemu_thread_exit.
Interesting. (I have a patch I put together on Friday and haven't tested yet that just uses the win32-style "explicitly run notifiers in exit and at end of thread_start".) thanks -- PMM