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

Unified Diff: ppapi/native_client/src/trusted/plugin/pnacl_streaming_translate_thread.cc

Issue 10828019: Better handling for NULL PutBytes arg in Pnacl streaming translation thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another way Created 8 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698