Fix scenario where the timeout for atomic wait is set to negative number (#1767)

The code, when received -1, performed -1/1000 operation which rounds to 0,
i.e. no wait (instead of infinite wait)
This commit is contained in:
Marcin Kolny 2022-11-29 10:45:07 +00:00 committed by GitHub
parent 8d2aedca77
commit 4cbfeec1f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -385,10 +385,8 @@ wasm_runtime_atomic_wait(WASMModuleInstanceCommon *module, void *address,
/* condition wait start */
os_mutex_lock(&wait_node->wait_lock);
if (timeout < 0)
timeout = BHT_WAIT_FOREVER;
os_cond_reltimedwait(&wait_node->wait_cond, &wait_node->wait_lock,
timeout / 1000);
timeout < 0 ? BHT_WAIT_FOREVER : timeout / 1000);
os_mutex_unlock(&wait_node->wait_lock);