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

Unified Diff: native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc

Issue 242533005: [NaCl SDK] nacl_io: Add flow control the JavaScript pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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: native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
index aeb54d5d37f6e5c7cebe95d9791a495360310a02..90c6e7586e63cf52eac693831379a394993529d2 100644
--- a/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.cc
@@ -20,9 +20,12 @@ const size_t kDefaultPipeSize = 512 * 1024;
namespace nacl_io {
PipeNode::PipeNode(Filesystem* fs)
- : StreamNode(fs), pipe_(new PipeEventEmitter(kDefaultPipeSize)) {}
+ : StreamNode(fs), pipe_(new PipeEventEmitter(kDefaultPipeSize)) {
+}
-EventEmitter* PipeNode::GetEventEmitter() { return pipe_.get(); }
+PipeEventEmitter* PipeNode::GetEventEmitter() {
+ return pipe_.get();
+}
Error PipeNode::Read(const HandleAttr& attr,
void* buf,
@@ -32,11 +35,13 @@ Error PipeNode::Read(const HandleAttr& attr,
EventListenerLock wait(GetEventEmitter());
Error err = wait.WaitOnEvent(POLLIN, ms);
+ if (err == ETIMEDOUT)
+ err = EWOULDBLOCK;
if (err)
return err;
- *out_bytes = pipe_->Read_Locked(static_cast<char*>(buf), count);
- return 0;
+ return GetEventEmitter()->Read_Locked(static_cast<char*>(buf), count,
+ out_bytes);
}
Error PipeNode::Write(const HandleAttr& attr,
@@ -47,11 +52,13 @@ Error PipeNode::Write(const HandleAttr& attr,
EventListenerLock wait(GetEventEmitter());
Error err = wait.WaitOnEvent(POLLOUT, ms);
+ if (err == ETIMEDOUT)
+ err = EWOULDBLOCK;
if (err)
return err;
- *out_bytes = pipe_->Write_Locked(static_cast<const char*>(buf), count);
- return 0;
+ return GetEventEmitter()->Write_Locked(static_cast<const char*>(buf),
+ count, out_bytes);
}
} // namespace nacl_io
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/pipe/pipe_node.h ('k') | native_client_sdk/src/libraries/nacl_io/typed_fs_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698