]> git.ipfire.org Git - thirdparty/libvirt.git/commit
rpc: finish all threads before exiting main loop
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 23 Jul 2020 06:53:04 +0000 (09:53 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Mon, 7 Sep 2020 06:33:59 +0000 (09:33 +0300)
commit94e45d1042e21e03a15ce993f90fbef626f1ae41
treed6ce90f52b7951f31d665a170bf1a9d0c41ac1a1
parentb776dfa8e881c868dc554c5c245f15c49332ce80
rpc: finish all threads before exiting main loop

Currently we have issues like [1] on libvirtd shutdown as we cleanup while RPC
and other threads are still running. Let's finish all threads other then main
before cleanup.

The approach to finish threads is suggested in [2]. In order to finish RPC
threads serving API calls we let the event loop run but stop accepting new API
calls and block processing any pending API calls. We also inform all drivers of
shutdown so they can prepare for shutdown too. Then we wait for all RPC threads
and driver's background thread to finish. If finishing takes more then 15s we
just exit as we can't safely cleanup in time.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1828207
[2] https://www.redhat.com/archives/libvir-list/2020-April/msg01328.html

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/remote/remote_daemon.c
src/rpc/virnetdaemon.c