This reverts commit
edc18749bd5dfb7e12513d3978f78f9b56104fd6.
The proposed fix is incorrect. It marks the "run_once" code as having
finished before it has. The intended semantics of run_once is that no
threads should proceed until the code has run exactly once. With this
change the "second" thread will think the run_once code has already been
run and will continue, even though it is still in progress. This could
result in a crash or other incorrect behaviour.
Reviewed-by: Tim Hudson <tjh@openssl.org>
do {
result = InterlockedCompareExchange(lock, ONCE_ININIT, ONCE_UNINITED);
if (result == ONCE_UNINITED) {
- *lock = ONCE_DONE;
init();
+ *lock = ONCE_DONE;
return 1;
}
} while (result == ONCE_ININIT);