File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -353,7 +353,7 @@ void OS::PrintErr(const char* format, ...) {
353353}
354354
355355void OS::Init () {
356- if (async_get_default_dispatcher () == NULL ) {
356+ if (async_get_default_dispatcher () == nullptr ) {
357357 async_loop_create (&kAsyncLoopConfigAttachToCurrentThread , &message_loop);
358358 async_set_default_dispatcher (async_loop_get_dispatcher (message_loop));
359359 async_loop_start_thread (message_loop, " Fuchsia async loop" , nullptr );
@@ -368,9 +368,19 @@ void OS::Init() {
368368}
369369
370370void OS::Cleanup () {
371+ if (message_loop != nullptr ) {
372+ async_loop_shutdown (message_loop);
373+ }
374+
371375 metrics = nullptr ;
372376 component_inspector = nullptr ;
377+
373378 if (message_loop != nullptr ) {
379+ // Check message_loop is still the default dispatcher before clearing it.
380+ if (async_get_default_dispatcher () ==
381+ async_loop_get_dispatcher (message_loop)) {
382+ async_set_default_dispatcher (nullptr );
383+ }
374384 async_loop_destroy (message_loop);
375385 message_loop = nullptr ;
376386 }
You can’t perform that action at this time.
0 commit comments