Skip to content

Commit

Permalink
migration/multifd: Unify multifd_send_thread error paths
Browse files Browse the repository at this point in the history
The preferred usage of the Error type is to always set both the return
code and the error when a failure happens. As all code called from the
send thread follows this pattern, we'll always have the return code
and the error set at the same time.

Aside from the convention, in this piece of code this must be the
case, otherwise the if (ret != 0) would be exiting the thread without
calling multifd_send_terminate_threads() which is incorrect.

Unify both paths to make it clear that both are taken when there's an
error.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231012134343.23757-3-farosas@suse.de>
  • Loading branch information
Fabiano Rosas authored and Juan Quintela committed Oct 16, 2023
1 parent 8560332 commit 6f1558d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions migration/multifd.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,19 +753,13 @@ static void *multifd_send_thread(void *opaque)
}

out:
if (local_err) {
if (ret) {
assert(local_err);
trace_multifd_send_error(p->id);
multifd_send_terminate_threads(local_err);
error_free(local_err);
}

/*
* 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);
error_free(local_err);
}

qemu_mutex_lock(&p->mutex);
Expand Down

0 comments on commit 6f1558d

Please sign in to comment.