diff options
| author | Nick Brassel <nick@tzarc.org> | 2023-12-21 09:32:19 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-21 09:32:19 +1100 |
| commit | 2661ee282a7edfdff299d2ccfc298dac75cf65e4 (patch) | |
| tree | 8675ab8c6c294d2c5d12b8d9a533c77c88f85c33 /quantum/deferred_exec.c | |
| parent | 3afa2a9439a74c4f4d906dcb1dfa975f13fc6763 (diff) | |
[Bugfix] Manipulate deferred executor slot only if tokens match (#22722)
Diffstat (limited to 'quantum/deferred_exec.c')
| -rw-r--r-- | quantum/deferred_exec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/quantum/deferred_exec.c b/quantum/deferred_exec.c index a0046a9648..b3be3747d4 100644 --- a/quantum/deferred_exec.c +++ b/quantum/deferred_exec.c | |||
| @@ -124,13 +124,19 @@ void deferred_exec_advanced_task(deferred_executor_t *table, size_t table_count, | |||
| 124 | 124 | ||
| 125 | // Run through each of the executors | 125 | // Run through each of the executors |
| 126 | for (int i = 0; i < table_count; ++i) { | 126 | for (int i = 0; i < table_count; ++i) { |
| 127 | deferred_executor_t *entry = &table[i]; | 127 | deferred_executor_t *entry = &table[i]; |
| 128 | deferred_token curr_token = entry->token; | ||
| 128 | 129 | ||
| 129 | // Check if we're supposed to execute this entry | 130 | // Check if we're supposed to execute this entry |
| 130 | if (entry->token != INVALID_DEFERRED_TOKEN && ((int32_t)TIMER_DIFF_32(entry->trigger_time, now)) <= 0) { | 131 | if (curr_token != INVALID_DEFERRED_TOKEN && ((int32_t)TIMER_DIFF_32(entry->trigger_time, now)) <= 0) { |
| 131 | // Invoke the callback and work work out if we should be requeued | 132 | // Invoke the callback and work work out if we should be requeued |
| 132 | uint32_t delay_ms = entry->callback(entry->trigger_time, entry->cb_arg); | 133 | uint32_t delay_ms = entry->callback(entry->trigger_time, entry->cb_arg); |
| 133 | 134 | ||
| 135 | // If the token has changed, then the callback has canceled and re-queued. Skip further processing. | ||
| 136 | if (entry->token != curr_token) { | ||
| 137 | continue; | ||
| 138 | } | ||
| 139 | |||
| 134 | // Update the trigger time if we have to repeat, otherwise clear it out | 140 | // Update the trigger time if we have to repeat, otherwise clear it out |
| 135 | if (delay_ms > 0) { | 141 | if (delay_ms > 0) { |
| 136 | // Intentionally add just the delay to the existing trigger time -- this ensures the next | 142 | // Intentionally add just the delay to the existing trigger time -- this ensures the next |
