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

Unified Diff: runtime/bin/process_win.cc

Issue 2596543002: Fix Process.runSync error handling. (Closed)
Patch Set: Address comments Created 4 years 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 | « runtime/bin/process_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_win.cc
diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc
index a2d93a4babcc9bc74f89fbd23f01bc6c32cd07a9..c0cb06bb3306030c87574cc66a9a89f83a8227f1 100644
--- a/runtime/bin/process_win.cc
+++ b/runtime/bin/process_win.cc
@@ -714,32 +714,35 @@ class BufferList : public BufferListBase {
// overlapped read.
void DataIsRead(intptr_t size) {
ASSERT(read_pending_ == true);
- data_size_ += size;
- free_size_ -= size;
- ASSERT(free_size_ >= 0);
+ set_data_size(data_size() + size);
+ set_free_size(free_size() - size);
+ ASSERT(free_size() >= 0);
read_pending_ = false;
}
// The access to the read buffer for overlapped read.
- void GetReadBuffer(uint8_t** buffer, intptr_t* size) {
+ bool GetReadBuffer(uint8_t** buffer, intptr_t* size) {
ASSERT(!read_pending_);
- if (free_size_ == 0) {
- Allocate();
+ if (free_size() == 0) {
+ if (!Allocate()) {
+ return false;
+ }
}
- ASSERT(free_size_ > 0);
- ASSERT(free_size_ <= kBufferSize);
+ ASSERT(free_size() > 0);
+ ASSERT(free_size() <= kBufferSize);
*buffer = FreeSpaceAddress();
- *size = free_size_;
+ *size = free_size();
read_pending_ = true;
+ return true;
}
- intptr_t GetDataSize() { return data_size_; }
+ intptr_t GetDataSize() { return data_size(); }
uint8_t* GetFirstDataBuffer() {
- ASSERT(head_ != NULL);
- ASSERT(head_ == tail_);
- ASSERT(data_size_ <= kBufferSize);
- return head_->data_;
+ ASSERT(head() != NULL);
+ ASSERT(head() == tail());
+ ASSERT(data_size() <= kBufferSize);
+ return head()->data();
}
void FreeDataBuffer() { Free(); }
@@ -776,7 +779,9 @@ class OverlappedHandle {
ClearOverlapped();
uint8_t* buffer;
intptr_t buffer_size;
- buffer_.GetReadBuffer(&buffer, &buffer_size);
+ if (!buffer_.GetReadBuffer(&buffer, &buffer_size)) {
+ return false;
+ }
BOOL ok = ReadFile(handle_, buffer, buffer_size, NULL, &overlapped_);
if (!ok) {
return (GetLastError() == ERROR_IO_PENDING);
@@ -793,6 +798,10 @@ class OverlappedHandle {
void FreeDataBuffer() { return buffer_.FreeDataBuffer(); }
+#if defined(DEBUG)
+ bool IsEmpty() const { return buffer_.IsEmpty(); }
+#endif
+
void Close() {
CloseHandle(handle_);
CloseHandle(event_);
@@ -882,6 +891,8 @@ bool Process::Wait(intptr_t pid,
// All handles closed and all data read.
result->set_stdout_data(oh[0].GetData());
result->set_stderr_data(oh[1].GetData());
+ DEBUG_ASSERT(oh[0].IsEmpty());
+ DEBUG_ASSERT(oh[1].IsEmpty());
// Calculate the exit code.
ASSERT(oh[2].GetDataSize() == 8);
« no previous file with comments | « runtime/bin/process_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698