Commit 0760c29
committed
netplay: only reinit preempt frames if core is running
deinit_netplay unconditionally calls preempt_init at the bottom
of its body. This is appropriate when netplay is being toggled
off mid-session - we want to restore preempt frames so the user
gets runahead back. But deinit_netplay is also called from two
shutdown contexts where the call is wasted work or worse:
- RARCH_CTL_MAIN_DEINIT (retroarch.c:8511) at full app
shutdown: preempt frames will be torn down moments later
by CMD_EVENT_CORE_DEINIT's preempt_deinit.
- retroarch_main_init's error: label (retroarch.c:8431) at
init failure: same teardown follows.
Beyond the wasted allocation, preempt_init at runahead.c:1501
synchronously calls runloop_st->current_core.retro_run() when
frame_count is 0. Firing a synchronous retro_run from inside
a deinit chain - while RARCH_CTL_MAIN_DEINIT is on the stack
or while we're unwinding from a failed init - is a surprising
side effect that any future change to retro_run could turn
into a bug.
Gate the call on RUNLOOP_FLAG_CORE_RUNNING. The flag is cleared
at the top of CMD_EVENT_UNLOAD_CORE (retroarch.c:3749), so the
shutdown paths see it unset and skip preempt_init. The mid-
session toggle paths (CMD_EVENT_NETPLAY_DEINIT from the netplay
menu actions in CMD_EVENT_NETPLAY_ENABLE_HOST etc.) see it set
and call preempt_init as before.1 parent 0ce7158 commit 0760c29
1 file changed
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9070 | 9070 | | |
9071 | 9071 | | |
9072 | 9072 | | |
9073 | | - | |
9074 | | - | |
| 9073 | + | |
| 9074 | + | |
| 9075 | + | |
| 9076 | + | |
| 9077 | + | |
| 9078 | + | |
| 9079 | + | |
| 9080 | + | |
| 9081 | + | |
| 9082 | + | |
| 9083 | + | |
| 9084 | + | |
| 9085 | + | |
| 9086 | + | |
| 9087 | + | |
| 9088 | + | |
9075 | 9089 | | |
9076 | 9090 | | |
9077 | 9091 | | |
| |||
0 commit comments