Index: ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc b/ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc |
index f8c79fafcc7f7cb3dd3413a42b6c627e9c73047f..52375002cb69c777b2fe8a67bb4410eae2d7c181 100644 |
--- a/ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc |
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc |
@@ -60,23 +60,31 @@ void PnaclStreamingTranslateThread::PutBytes(std::vector<char>* bytes, |
PLUGIN_PRINTF(("PutBytes, this %p bytes %p, size %d, count %d\n", this, bytes, |
bytes ? bytes->size(): 0, count)); |
size_t buffer_size = 0; |
+ // If we are done (error or not), Signal the translation thread to stop. |
+ if (count <= PP_OK) { |
+ NaClXMutexLock(&cond_mu_); |
+ done_ = true; |
+ NaClXCondVarSignal(&buffer_cond_); |
+ NaClXMutexUnlock(&cond_mu_); |
+ return; |
+ } |
+ |
+ CHECK(bytes != NULL); |
// Ensure that the buffer we send to the translation thread is the right size |
// (count can be < the buffer size). This can be done without the lock. |
- if (bytes != NULL && count >= 0) { |
- buffer_size = bytes->size(); |
- bytes->resize(count); |
- } |
+ buffer_size = bytes->size(); |
+ bytes->resize(count); |
+ |
NaClXMutexLock(&cond_mu_); |
- if (count == PP_OK || count < 0) { |
- done_ = true; |
- } else { |
- data_buffers_.push_back(std::vector<char>()); |
- bytes->swap(data_buffers_.back()); // Avoid copying the buffer data. |
- } |
+ |
+ data_buffers_.push_back(std::vector<char>()); |
+ bytes->swap(data_buffers_.back()); // Avoid copying the buffer data. |
+ |
NaClXCondVarSignal(&buffer_cond_); |
NaClXMutexUnlock(&cond_mu_); |
+ |
// Ensure the buffer we send back to the coordinator is the expected size |
- if (bytes != NULL) bytes->resize(buffer_size); |
+ bytes->resize(buffer_size); |
} |
void PnaclStreamingTranslateThread::DoTranslate() { |