| OLD | NEW |
| 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 "mojo/system/raw_channel.h" | 5 #include "mojo/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/uio.h> | 8 #include <sys/uio.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 ssize_t read_result = HANDLE_EINTR(read(fd_.get().fd, buffer, bytes_to_read)); | 105 ssize_t read_result = HANDLE_EINTR(read(fd_.get().fd, buffer, bytes_to_read)); |
| 106 | 106 |
| 107 if (read_result > 0) { | 107 if (read_result > 0) { |
| 108 *bytes_read = static_cast<size_t>(read_result); | 108 *bytes_read = static_cast<size_t>(read_result); |
| 109 return IO_SUCCEEDED; | 109 return IO_SUCCEEDED; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // |read_result == 0| means "end of file". | 112 // |read_result == 0| means "end of file". |
| 113 if (read_result == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) { | 113 if (read_result == 0 || (errno != EAGAIN && errno != EWOULDBLOCK)) { |
| 114 if (read_result != 0) | 114 PLOG_IF(ERROR, read_result != 0) << "read"; |
| 115 PLOG(ERROR) << "read"; | |
| 116 | 115 |
| 117 // Make sure that |OnFileCanReadWithoutBlocking()| won't be called again. | 116 // Make sure that |OnFileCanReadWithoutBlocking()| won't be called again. |
| 118 read_watcher_.reset(); | 117 read_watcher_.reset(); |
| 119 | 118 |
| 120 return IO_FAILED; | 119 return IO_FAILED; |
| 121 } | 120 } |
| 122 | 121 |
| 123 return ScheduleRead(); | 122 return ScheduleRead(); |
| 124 } | 123 } |
| 125 | 124 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 write_result = embedder::PlatformChannelWritev(fd_.get(), iov, | 166 write_result = embedder::PlatformChannelWritev(fd_.get(), iov, |
| 168 buffer_count); | 167 buffer_count); |
| 169 } | 168 } |
| 170 | 169 |
| 171 if (write_result >= 0) { | 170 if (write_result >= 0) { |
| 172 *bytes_written = static_cast<size_t>(write_result); | 171 *bytes_written = static_cast<size_t>(write_result); |
| 173 return IO_SUCCEEDED; | 172 return IO_SUCCEEDED; |
| 174 } | 173 } |
| 175 | 174 |
| 176 if (errno != EAGAIN && errno != EWOULDBLOCK) { | 175 if (errno != EAGAIN && errno != EWOULDBLOCK) { |
| 177 PLOG(ERROR) << "write of size " | 176 PLOG(ERROR) << "write"; |
| 178 << write_buffer_no_lock()->GetTotalBytesToWrite(); | |
| 179 return IO_FAILED; | 177 return IO_FAILED; |
| 180 } | 178 } |
| 181 | 179 |
| 182 return ScheduleWriteNoLock(); | 180 return ScheduleWriteNoLock(); |
| 183 } | 181 } |
| 184 | 182 |
| 185 RawChannel::IOResult RawChannelPosix::ScheduleWriteNoLock() { | 183 RawChannel::IOResult RawChannelPosix::ScheduleWriteNoLock() { |
| 186 write_lock().AssertAcquired(); | 184 write_lock().AssertAcquired(); |
| 187 | 185 |
| 188 DCHECK(!pending_write_); | 186 DCHECK(!pending_write_); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 314 |
| 317 // Static factory method declared in raw_channel.h. | 315 // Static factory method declared in raw_channel.h. |
| 318 // static | 316 // static |
| 319 scoped_ptr<RawChannel> RawChannel::Create( | 317 scoped_ptr<RawChannel> RawChannel::Create( |
| 320 embedder::ScopedPlatformHandle handle) { | 318 embedder::ScopedPlatformHandle handle) { |
| 321 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); | 319 return scoped_ptr<RawChannel>(new RawChannelPosix(handle.Pass())); |
| 322 } | 320 } |
| 323 | 321 |
| 324 } // namespace system | 322 } // namespace system |
| 325 } // namespace mojo | 323 } // namespace mojo |
| OLD | NEW |