From 4b7d2422fd083432cf2c882833b7ae5f9e356191 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 24 Oct 2020 21:32:57 +0200 Subject: [PATCH] Moved SLiRP event destruction to the thread to fix the Settings restart crash. --- src/network/net_slirp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index 02ae6556e..80161b4be 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -392,6 +392,9 @@ poll_thread(void *arg) slirp_log("SLiRP: polling stopped.\n"); thread_set_event(slirp->poll_state); + /* Destroy event here to avoid a crash. */ + slirp_log("SLiRP: thread ended\n"); + thread_destroy_event(slirp->poll_state); /* Free here instead of immediately freeing the global slirp on the main thread to avoid a race condition. */ slirp_cleanup(slirp->slirp); @@ -451,8 +454,6 @@ net_slirp_close(void) /* Wait for the thread to finish. */ slirp_log("SLiRP: waiting for thread to end...\n"); thread_wait_event(slirp->poll_state, -1); - slirp_log("SLiRP: thread ended\n"); - thread_destroy_event(slirp->poll_state); } /* Shutdown work is done by the thread on its local copy of slirp. */