Skip to content

Commit 4cbfeec

Browse files
authored
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)
1 parent 8d2aedc commit 4cbfeec

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

core/iwasm/common/wasm_shared_memory.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,8 @@ wasm_runtime_atomic_wait(WASMModuleInstanceCommon *module, void *address,
385385
/* condition wait start */
386386
os_mutex_lock(&wait_node->wait_lock);
387387

388-
if (timeout < 0)
389-
timeout = BHT_WAIT_FOREVER;
390388
os_cond_reltimedwait(&wait_node->wait_cond, &wait_node->wait_lock,
391-
timeout / 1000);
389+
timeout < 0 ? BHT_WAIT_FOREVER : timeout / 1000);
392390

393391
os_mutex_unlock(&wait_node->wait_lock);
394392

0 commit comments

Comments
 (0)