Modify poll_oneoff in libc-wasi to make it interruptible (#1951)
This commit is contained in:
@ -111,6 +111,7 @@ notify_stale_threads_on_exception(WASMModuleInstanceCommon *module_inst)
|
||||
{
|
||||
AtomicWaitAddressArgs args = { 0 };
|
||||
uint32 i = 0, total_elem_count = 0;
|
||||
uint64 total_elem_count_size = 0;
|
||||
|
||||
os_mutex_lock(&shared_memory_list_lock);
|
||||
|
||||
@ -118,8 +119,15 @@ notify_stale_threads_on_exception(WASMModuleInstanceCommon *module_inst)
|
||||
bh_hash_map_traverse(wait_map, wait_map_address_count_callback,
|
||||
(void *)&total_elem_count);
|
||||
|
||||
if (!total_elem_count) {
|
||||
os_mutex_unlock(&shared_memory_list_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
/* allocate memory */
|
||||
if (!(args.addr = wasm_runtime_malloc(sizeof(void *) * total_elem_count))) {
|
||||
total_elem_count_size = (uint64)sizeof(void *) * total_elem_count;
|
||||
if (total_elem_count_size >= UINT32_MAX
|
||||
|| !(args.addr = wasm_runtime_malloc((uint32)total_elem_count_size))) {
|
||||
LOG_ERROR(
|
||||
"failed to allocate memory for list of atomic wait addresses");
|
||||
os_mutex_unlock(&shared_memory_list_lock);
|
||||
|
||||
Reference in New Issue
Block a user