From: Cheng Zhao Date: Mon, 11 Nov 2013 08:57:40 +0000 (+0800) Subject: Fix a possible dead lock when quiting. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5ffa4dc770c1e8e0cd613fb24655dcc58090f2f;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Fix a possible dead lock when quiting. It could happen that we are quitting when the embed thread is still waiting for the main thread, so we make sure embed thread is always signaled when quitting. --- diff --git a/common/node_bindings.cc b/common/node_bindings.cc index 963f8fe..3e80041 100644 --- a/common/node_bindings.cc +++ b/common/node_bindings.cc @@ -39,10 +39,16 @@ NodeBindings::NodeBindings(bool is_browser) } NodeBindings::~NodeBindings() { - // Clear uv. + // Quit the embed thread. embed_closed_ = true; + uv_sem_post(&embed_sem_); WakeupEmbedThread(); + + // Wait for everything to be done. uv_thread_join(&embed_thread_); + message_loop_->RunUntilIdle(); + + // Clear uv. uv_sem_destroy(&embed_sem_); uv_timer_stop(&idle_timer_); }