From: yangguo@chromium.org Date: Wed, 28 Sep 2011 13:27:20 +0000 (+0000) Subject: Fixed deadlock in the debugger agent in Windows. X-Git-Tag: upstream/4.7.83~18332 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd575f7177d8ce6d30d29e639ca81e4988815abf;p=platform%2Fupstream%2Fv8.git Fixed deadlock in the debugger agent in Windows. BUG=v8:1723 TEST=cctest test-debug/DebuggerAgent Review URL: http://codereview.chromium.org/8069002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9469 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/platform-win32.cc b/src/platform-win32.cc index 898a2a3..46af4dc 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -1511,6 +1511,7 @@ class Thread::PlatformData : public Malloced { public: explicit PlatformData(HANDLE thread) : thread_(thread) {} HANDLE thread_; + unsigned thread_id_; }; @@ -1554,13 +1555,15 @@ void Thread::Start() { ThreadEntry, this, 0, - NULL)); + &data_->thread_id_)); } // Wait for thread to terminate. void Thread::Join() { - WaitForSingleObject(data_->thread_, INFINITE); + if (data_->thread_id_ != GetCurrentThreadId()) { + WaitForSingleObject(data_->thread_, INFINITE); + } } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index de60d49..2383f2d 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -5845,11 +5845,14 @@ TEST(DebuggerAgent) { const int kPort1 = 5858; const int kPort2 = 5857; const int kPort3 = 5856; + const int kPort4 = 5855; // Make a string with the port2 number. const int kPortBufferLen = 6; char port2_str[kPortBufferLen]; OS::SNPrintF(i::Vector(port2_str, kPortBufferLen), "%d", kPort2); + char port4_str[kPortBufferLen]; + OS::SNPrintF(i::Vector(port4_str, kPortBufferLen), "%d", kPort4); bool ok; @@ -5885,6 +5888,27 @@ TEST(DebuggerAgent) { debugger->StopAgent(); delete server; + + // Test responsiveness after connecting and disconnecting a client. + ok = debugger->StartAgent("test", kPort4); + CHECK(ok); + client = i::OS::CreateSocket(); + ok = client->Connect("localhost", port4_str); + CHECK(ok); + ok = client->Receive(&buf, 1) == 1; + CHECK(ok); + ok = client->Send( + "{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}", 49); + CHECK(ok); + client->Shutdown(); + delete client; + // Is the server still responsive? + client = i::OS::CreateSocket(); + ok = client->Connect("localhost", port4_str); + CHECK(ok); + client->Shutdown(); + delete client; + debugger->StopAgent(); }