William Horvath (@whrvth) commented about dlls/ntdll/unix/server.c:
/* A test on Windows 2000 shows that Windows always yields during a wait, but a wait that is hit by an event gets a priority boost as well. This seems to model that behavior the closest. */
- if (ret == STATUS_TIMEOUT) NtYieldExecution();
- if (ret == STATUS_TIMEOUT)
- {
int yield_ret = NtYieldExecution();
/* The following should only be reached from NtDelayExecution.
It never returns STATUS_TIMEOUT directly, and propagates
the result of the yield for zero-timeout waits.
Otherwise, it reports STATUS_SUCCESS. */
if (!select_op)
I assume the main problem with this patch is due to this check here. While this works correctly for now with how `server_wait` is used, it's just an extra thing to be careful about in the future.
However, the other options I considered also had tradeoffs: - Add an argument to `server_wait` to signal if we want the return value of the yield (best alternative) - Just yield again in `NtDelayExecution` itself, ignoring the fact that we already yielded, and return the result there like we do for the non-alertable case (second best alternative) - Move the yield outside of `server_wait` and duplicate it everywhere `server_wait` is called (terrible)
Maybe there's something else to consider, but the current version isn't so bad if you take these alternatives into account.