| Index: runtime/bin/socket_base_android.cc
|
| diff --git a/runtime/bin/socket_base_android.cc b/runtime/bin/socket_base_android.cc
|
| index 1f4feb803a15cd339c692ed388089d9acb2d33c9..0663a2936f47c12ba42c000f9ba22172c8e9cf3b 100644
|
| --- a/runtime/bin/socket_base_android.cc
|
| +++ b/runtime/bin/socket_base_android.cc
|
| @@ -62,11 +62,14 @@ intptr_t SocketBase::Available(intptr_t fd) {
|
| }
|
|
|
|
|
| -intptr_t SocketBase::Read(intptr_t fd, void* buffer, intptr_t num_bytes) {
|
| +intptr_t SocketBase::Read(intptr_t fd,
|
| + void* buffer,
|
| + intptr_t num_bytes,
|
| + SocketOpKind sync) {
|
| ASSERT(fd >= 0);
|
| ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes));
|
| ASSERT(EAGAIN == EWOULDBLOCK);
|
| - if ((read_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| + if ((sync == kAsync) && (read_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| // If the read would block we need to retry and therefore return 0
|
| // as the number of bytes written.
|
| read_bytes = 0;
|
| @@ -78,12 +81,13 @@ intptr_t SocketBase::Read(intptr_t fd, void* buffer, intptr_t num_bytes) {
|
| intptr_t SocketBase::RecvFrom(intptr_t fd,
|
| void* buffer,
|
| intptr_t num_bytes,
|
| - RawAddr* addr) {
|
| + RawAddr* addr,
|
| + SocketOpKind sync) {
|
| ASSERT(fd >= 0);
|
| socklen_t addr_len = sizeof(addr->ss);
|
| ssize_t read_bytes = TEMP_FAILURE_RETRY(
|
| recvfrom(fd, buffer, num_bytes, 0, &addr->addr, &addr_len));
|
| - if ((read_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| + if ((sync == kAsync) && (read_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| // If the read would block we need to retry and therefore return 0
|
| // as the number of bytes written.
|
| read_bytes = 0;
|
| @@ -94,11 +98,12 @@ intptr_t SocketBase::RecvFrom(intptr_t fd,
|
|
|
| intptr_t SocketBase::Write(intptr_t fd,
|
| const void* buffer,
|
| - intptr_t num_bytes) {
|
| + intptr_t num_bytes,
|
| + SocketOpKind sync) {
|
| ASSERT(fd >= 0);
|
| ssize_t written_bytes = TEMP_FAILURE_RETRY(write(fd, buffer, num_bytes));
|
| ASSERT(EAGAIN == EWOULDBLOCK);
|
| - if ((written_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| + if ((sync == kAsync) && (written_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| // If the would block we need to retry and therefore return 0 as
|
| // the number of bytes written.
|
| written_bytes = 0;
|
| @@ -110,13 +115,14 @@ intptr_t SocketBase::Write(intptr_t fd,
|
| intptr_t SocketBase::SendTo(intptr_t fd,
|
| const void* buffer,
|
| intptr_t num_bytes,
|
| - const RawAddr& addr) {
|
| + const RawAddr& addr,
|
| + SocketOpKind sync) {
|
| ASSERT(fd >= 0);
|
| ssize_t written_bytes =
|
| TEMP_FAILURE_RETRY(sendto(fd, buffer, num_bytes, 0, &addr.addr,
|
| SocketAddress::GetAddrLength(addr)));
|
| ASSERT(EAGAIN == EWOULDBLOCK);
|
| - if ((written_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| + if ((sync == kAsync) && (written_bytes == -1) && (errno == EWOULDBLOCK)) {
|
| // If the would block we need to retry and therefore return 0 as
|
| // the number of bytes written.
|
| written_bytes = 0;
|
|
|