migration/multifd: always post the sync semaphores when sendesr exit
PATCH 1/1 migration/multifd: always post the sync semaphores when sendesr exit
The sem_sync and channels_ready semaphores are used by the multifd sender threads to synchronize with the migration thread. It is possible that one of the sender threads exits due to an error (e.g. occured when writing to the socket). The error thread sets multifd_send_state->exiting to force other sender threads to exit. Those threads exit (due to the setting of multifd_send_state->exiting) won't post the sem_sync and channels_ready semaphores, as they didn't encounter any error (i.e. ret will be 0 when exits). In this case, if the migration thread is waiting on the sem_sync semaphores from all the sender threads, it will wait there forever, which is not expected.
Change the sender threads to always post the sem_sync and channels_ready semaphores when exit. This will unblock the migration thread in the above case to exit. If the main thread isn't waiting on the semaphores when the sender threads exits, posting on the semaphores will just be like a noop.
--- migration/multifd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
migration/multifd.c +2 -4
@@ -757,10 +757,8 @@ out:* Error happen, I will exit, but I can't just leave, tell * who pay attention to me. */ -if (ret !=0 ) { -qemu_sem_post (&p->sem_sync); -qemu_sem_post (&multifd_send_state->channels_ready); - } +qemu_sem_post (&p->sem_sync); +qemu_sem_post (&multifd_send_state->channels_ready);qemu_mutex_lock (&p->mutex); p->running = false;
Signature · 1 line
2.27.0