Chromium Code Reviews| Index: src/trusted/debug_stub/win/thread_impl.cc |
| diff --git a/src/trusted/debug_stub/win/thread_impl.cc b/src/trusted/debug_stub/win/thread_impl.cc |
| index 3eab93e289a2354ed6df2e8ca6e239ab0eb72343..4f61a38ba33fcc9a194c78c558ebc26166a58d40 100644 |
| --- a/src/trusted/debug_stub/win/thread_impl.cc |
| +++ b/src/trusted/debug_stub/win/thread_impl.cc |
| @@ -9,6 +9,7 @@ |
| #include <exception> |
| #include <stdexcept> |
| +#include "native_client/src/shared/platform/nacl_log.h" |
| #include "native_client/src/trusted/port/mutex.h" |
| #include "native_client/src/trusted/port/thread.h" |
| @@ -209,8 +210,8 @@ static int GetSizeofRegInCtx(int32_t num) { |
| class Thread : public IThread { |
| public: |
| - explicit Thread(uint32_t id) : ref_(1), id_(id), |
| - handle_(NULL), state_(RUNNING) { |
| + Thread(uint32_t id, struct NaClAppThread *) |
|
Mark Seaborn
2012/05/09 00:06:06
FWIW, the same criticism of unused fields applies
eaeltsin
2012/05/09 06:01:32
The field is back for now.
|
| + : ref_(1), id_(id), handle_(NULL), state_(RUNNING) { |
| handle_ = OpenThread(THREAD_ALL_ACCESS, false, id); |
| memset(&context_, 0, sizeof(context_)); |
| context_.ContextFlags = CONTEXT_ALL; |
| @@ -368,32 +369,39 @@ class Thread : public IThread { |
| friend class IThread; |
| }; |
| -IThread* IThread::Acquire(uint32_t id, bool create) { |
| +IThread* IThread::Create(uint32_t id, struct NaClAppThread* natp) { |
| MutexLock lock(ThreadGetLock()); |
| Thread* thread; |
| ThreadMap_t &map = *ThreadGetMap(); |
| - // Check if we have that thread |
| if (map.count(id)) { |
| - thread = static_cast<Thread*>(map[id]); |
| - thread->ref_++; |
| - return thread; |
| + NaClLog(LOG_FATAL, "IThread::Create: thread 0x%x already exists\n", id); |
| + return NULL; |
|
Mark Seaborn
2012/05/09 00:06:06
You don't need a return after a LOG_FATAL.
eaeltsin
2012/05/09 06:01:32
Done.
|
| } |
| - // If not, can we create it? |
| - if (create) { |
| - // If not add it to the map |
| - thread = new Thread(id); |
| - if (NULL == thread->handle_) { |
| - delete thread; |
| - return NULL; |
| - } |
| + thread = new Thread(id, natp); |
| + if (NULL == thread->handle_) { |
| + delete thread; |
| + return NULL; |
| + } |
| + |
| + map[id] = thread; |
| + return thread; |
| +} |
| + |
| +IThread* IThread::Acquire(uint32_t id) { |
| + MutexLock lock(ThreadGetLock()); |
| + Thread* thread; |
| + ThreadMap_t &map = *ThreadGetMap(); |
| - map[id] = thread; |
| - return thread; |
| + if (map.count(id) == 0) { |
| + NaClLog(LOG_FATAL, "IThread::Acquire: thread 0x%x does not exist\n", id); |
| + return NULL; |
|
Mark Seaborn
2012/05/09 00:06:06
ditto
eaeltsin
2012/05/09 06:01:32
Done.
|
| } |
| - return NULL; |
| + thread = static_cast<Thread*>(map[id]); |
| + thread->ref_++; |
| + return thread; |
| } |
| void IThread::Release(IThread *ithread) { |