Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: src/debug.cc

Issue 53089: Fixed test memory leaks (Closed)
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index 7e0b298925e222070f56bde5fd6af03403d83e65..3813201d0ebf84c46ca4795de956fb0d067b6d0a 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -1737,6 +1737,12 @@ void Debugger::SetEventListener(Handle<Object> callback,
}
+void Debugger::TearDown() {
+ if (message_thread_ != NULL)
+ message_thread_->Stop();
Søren Thygesen Gjesse 2009/03/26 10:50:09 Please add { }'s Why don't you have to delete mes
Christian Plesner Hansen 2009/03/27 00:24:26 Done. Technically it's not a leak as long as ther
+}
+
+
void Debugger::SetMessageHandler(v8::DebugMessageHandler handler, void* data) {
message_handler_ = handler;
message_handler_data_ = data;
@@ -1852,16 +1858,23 @@ void Debugger::StopAgent() {
DebugMessageThread::DebugMessageThread()
: host_running_(true),
command_queue_(kQueueInitialSize),
- message_queue_(kQueueInitialSize) {
+ message_queue_(kQueueInitialSize),
+ keep_running_(true) {
command_received_ = OS::CreateSemaphore(0);
message_received_ = OS::CreateSemaphore(0);
}
-// Does not free resources held by DebugMessageThread
-// because this cannot be done thread-safely.
+// Should only be done after the thread is done running.
DebugMessageThread::~DebugMessageThread() {
+ delete command_received_;
+ delete message_received_;
}
+void DebugMessageThread::Stop() {
+ keep_running_ = false;
+ SendMessage(Vector<uint16_t>(NULL, 0));
+ Join();
+}
// Puts an event coming from V8 on the queue. Creates
// a copy of the JSON formatted event string managed by the V8.
@@ -1909,7 +1922,7 @@ bool DebugMessageThread::SetEventJSONFromEvent(Handle<Object> event_data) {
void DebugMessageThread::Run() {
// Sends debug events to an installed debugger message callback.
- while (true) {
+ while (keep_running_) {
// Wait and Get are paired so that semaphore count equals queue length.
message_received_->Wait();
Logger::DebugTag("Get message from event message_queue.");

Powered by Google App Engine
This is Rietveld 408576698