Chromium Code Reviews| Index: runtime/bin/dbg_connection.cc |
| =================================================================== |
| --- runtime/bin/dbg_connection.cc (revision 22486) |
| +++ runtime/bin/dbg_connection.cc (working copy) |
| @@ -22,7 +22,7 @@ |
| namespace bin { |
| int DebuggerConnectionHandler::listener_fd_ = -1; |
| -dart::Monitor DebuggerConnectionHandler::handler_lock_; |
| +dart::Monitor* DebuggerConnectionHandler::handler_lock_ = NULL; |
| // TODO(asiva): Remove this once we have support for multiple debugger |
| // connections. For now we just store the single debugger connection |
| @@ -280,7 +280,10 @@ |
| void DebuggerConnectionHandler::StartHandler(const char* address, |
| int port_number) { |
| - MonitorLocker ml(&handler_lock_); |
| + handler_lock_ = new dart::Monitor(); |
|
hausner
2013/05/08 15:26:48
What if two threads call this function by accident
siva
2013/05/08 20:48:12
I changed the initialization of handler_lock_ into
|
| + ASSERT(handler_lock_ != NULL); |
| + |
| + MonitorLocker ml(handler_lock_); |
| if (listener_fd_ != -1) { |
| return; // The debugger connection handler was already started. |
| } |
| @@ -307,7 +310,8 @@ |
| void DebuggerConnectionHandler::WaitForConnection() { |
| - MonitorLocker ml(&handler_lock_); |
| + ASSERT(handler_lock_ != NULL); |
| + MonitorLocker ml(handler_lock_); |
| while (!IsConnected()) { |
| dart::Monitor::WaitResult res = ml.Wait(); |
| ASSERT(res == dart::Monitor::kNotified); |
| @@ -316,13 +320,15 @@ |
| void DebuggerConnectionHandler::SendMsg(int debug_fd, dart::TextBuffer* msg) { |
| - MonitorLocker ml(&handler_lock_); |
| + ASSERT(handler_lock_ != NULL); |
| + MonitorLocker ml(handler_lock_); |
| SendMsgHelper(debug_fd, msg); |
| } |
| void DebuggerConnectionHandler::BroadcastMsg(dart::TextBuffer* msg) { |
| - MonitorLocker ml(&handler_lock_); |
| + ASSERT(handler_lock_ != NULL); |
| + MonitorLocker ml(handler_lock_); |
| // TODO(asiva): Once we support connection to multiple debuggers |
| // we need to send the message to all of them. |
| ASSERT(singleton_handler != NULL); |
| @@ -371,7 +377,8 @@ |
| void DebuggerConnectionHandler::AcceptDbgConnection(int debug_fd) { |
| AddNewDebuggerConnection(debug_fd); |
| { |
| - MonitorLocker ml(&handler_lock_); |
| + ASSERT(handler_lock_ != NULL); |
| + MonitorLocker ml(handler_lock_); |
| ml.NotifyAll(); |
| } |
| // TODO(asiva): Once we implement support for multiple connections |