File tree Expand file tree Collapse file tree
product-mini/platforms/posix Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,21 +535,23 @@ void *
535535timeout_thread (void * vp )
536536{
537537 const struct timeout_arg * arg = vp ;
538- uint32 left = arg -> timeout_ms ;
538+ const uint64 end_time =
539+ os_time_get_boot_us () + (uint64 )arg -> timeout_ms * 1000 ;
539540 while (!arg -> cancel ) {
540- uint32 ms ;
541- if (left >= 100 ) {
542- ms = 100 ;
543- }
544- else {
545- ms = left ;
546- }
547- os_usleep ((uint64 )ms * 1000 );
548- left -= ms ;
549- if (left == 0 ) {
541+ const uint64 now = os_time_get_boot_us ();
542+ if ((int64 )(now - end_time ) > 0 ) {
550543 wasm_runtime_terminate (arg -> inst );
551544 break ;
552545 }
546+ const uint64 left_us = end_time - now ;
547+ uint32 us ;
548+ if (left_us >= 100 * 1000 ) {
549+ us = 100 * 1000 ;
550+ }
551+ else {
552+ us = left_us ;
553+ }
554+ os_usleep (us );
553555 }
554556 return NULL ;
555557}
You can’t perform that action at this time.
0 commit comments