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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/devfs/tty_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: rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/devfs/tty_node.h" 5 #include "nacl_io/devfs/tty_node.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 Error TtyNode::Read(const HandleAttr& attr, 104 Error TtyNode::Read(const HandleAttr& attr,
105 void* buf, 105 void* buf,
106 size_t count, 106 size_t count,
107 int* out_bytes) { 107 int* out_bytes) {
108 EventListenerLock wait(GetEventEmitter()); 108 EventListenerLock wait(GetEventEmitter());
109 *out_bytes = 0; 109 *out_bytes = 0;
110 110
111 // If interrupted, return 111 // If interrupted, return
112 Error err = wait.WaitOnEvent(POLLIN, -1); 112 Error err = wait.WaitOnEvent(POLLIN, -1);
113 if (err == ETIMEDOUT)
114 err = EWOULDBLOCK;
113 if (err != 0) 115 if (err != 0)
114 return err; 116 return err;
115 117
116 size_t bytes_to_copy = std::min(count, input_buffer_.size()); 118 size_t bytes_to_copy = std::min(count, input_buffer_.size());
117 if (IS_ICANON) { 119 if (IS_ICANON) {
118 // Only read up to (and including) the first newline 120 // Only read up to (and including) the first newline
119 std::deque<char>::iterator nl = 121 std::deque<char>::iterator nl =
120 std::find(input_buffer_.begin(), input_buffer_.end(), '\n'); 122 std::find(input_buffer_.begin(), input_buffer_.end(), '\n');
121 123
122 if (nl != input_buffer_.end()) { 124 if (nl != input_buffer_.end()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 291
290 Error TtyNode::Tcsetattr(int optional_actions, 292 Error TtyNode::Tcsetattr(int optional_actions,
291 const struct termios* termios_p) { 293 const struct termios* termios_p) {
292 AUTO_LOCK(node_lock_); 294 AUTO_LOCK(node_lock_);
293 termios_ = *termios_p; 295 termios_ = *termios_p;
294 return 0; 296 return 0;
295 } 297 }
296 298
297 } // namespace nacl_io 299 } // namespace nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698