File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -286,12 +286,31 @@ static void initVM()
286
286
uv_loop_init (loop );
287
287
}
288
288
289
+ void on_uvWalkForShutdown (uv_handle_t * handle , void * arg )
290
+ {
291
+ if (!uv_is_closing (handle ))
292
+ uv_close (handle , NULL );
293
+ }
294
+
295
+ static void uvShutdown () {
296
+ uv_loop_t * loop = getLoop ();
297
+ int result = uv_loop_close (loop );
298
+ if (result == UV_EBUSY )
299
+ {
300
+ uv_walk (loop , on_uvWalkForShutdown , NULL );
301
+ uv_run (loop , UV_RUN_ONCE );
302
+ }
303
+ result = uv_loop_close (loop );
304
+ if (result != 0 ) {
305
+ fprintf (stderr , "could not close UV event loop completely" );
306
+ }
307
+ }
308
+
289
309
static void freeVM ()
290
310
{
291
311
ioShutdown ();
292
312
schedulerShutdown ();
293
-
294
- uv_loop_close (loop );
313
+ uvShutdown ();
295
314
free (loop );
296
315
297
316
wrenFreeVM (vm );
You can’t perform that action at this time.
0 commit comments