summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbohu2017-03-28 16:51:23 -0500
committerbohu2017-03-28 17:04:38 -0500
commitec768709cc029d307b9e57e8dce193b7ee8c2321 (patch)
tree79368499d4a988a034006579fb088a389b44d9bf /qemu_pipe
parent79b30058992ddf678a261a59172a009d6a0db0ed (diff)
downloadplatform-system-core-ec768709cc029d307b9e57e8dce193b7ee8c2321.tar.gz
platform-system-core-ec768709cc029d307b9e57e8dce193b7ee8c2321.tar.xz
platform-system-core-ec768709cc029d307b9e57e8dce193b7ee8c2321.zip
Revert "Emulator: Enhance qemu_pipe.h to handle partial rw"
It broke master BUG: 36695011 This reverts commit 7b60bd95dfa07e86325b432465fb0043648f6c97. Change-Id: Idd45acb63b2e6112b4230de2c0609aa8f2092f45
Diffstat (limited to 'qemu_pipe')
-rw-r--r--qemu_pipe/qemu_pipe.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/qemu_pipe/qemu_pipe.cpp b/qemu_pipe/qemu_pipe.cpp
index ca3b79578..a4529deb8 100644
--- a/qemu_pipe/qemu_pipe.cpp
+++ b/qemu_pipe/qemu_pipe.cpp
@@ -22,10 +22,6 @@
22#include <errno.h> 22#include <errno.h>
23#include <stdio.h> 23#include <stdio.h>
24 24
25#include <android-base/file.h>
26
27using android::base::ReadFully;
28using android::base::WriteFully;
29 25
30// Define QEMU_PIPE_DEBUG if you want to print error messages when an error 26// Define QEMU_PIPE_DEBUG if you want to print error messages when an error
31// occurs during pipe operations. The macro should simply take a printf-style 27// occurs during pipe operations. The macro should simply take a printf-style
@@ -70,10 +66,15 @@ int qemu_pipe_open(const char* pipeName) {
70 66
71 // Write the pipe name, *including* the trailing zero which is necessary. 67 // Write the pipe name, *including* the trailing zero which is necessary.
72 size_t pipeNameLen = strlen(pipeName); 68 size_t pipeNameLen = strlen(pipeName);
73 if (!WriteFully(fd, pipeName, pipeNameLen + 1U)) { 69 ssize_t ret = TEMP_FAILURE_RETRY(write(fd, pipeName, pipeNameLen + 1U));
70 if (ret != (ssize_t)pipeNameLen + 1) {
74 QEMU_PIPE_DEBUG("%s: Could not connect to %s pipe service: %s", 71 QEMU_PIPE_DEBUG("%s: Could not connect to %s pipe service: %s",
75 __FUNCTION__, pipeName, strerror(errno)); 72 __FUNCTION__, pipeName, strerror(errno));
76 close(fd); 73 if (ret == 0) {
74 errno = ECONNRESET;
75 } else if (ret > 0) {
76 errno = EINVAL;
77 }
77 return -1; 78 return -1;
78 } 79 }
79 return fd; 80 return fd;
@@ -85,11 +86,13 @@ int qemu_pipe_open(const char* pipeName) {
85int qemu_pipe_frame_send(int fd, const void* buff, size_t len) { 86int qemu_pipe_frame_send(int fd, const void* buff, size_t len) {
86 char header[5]; 87 char header[5];
87 snprintf(header, sizeof(header), "%04zx", len); 88 snprintf(header, sizeof(header), "%04zx", len);
88 if (!WriteFully(fd, header, 4)) { 89 ssize_t ret = TEMP_FAILURE_RETRY(write(fd, header, 4));
90 if (ret != 4) {
89 QEMU_PIPE_DEBUG("Can't write qemud frame header: %s", strerror(errno)); 91 QEMU_PIPE_DEBUG("Can't write qemud frame header: %s", strerror(errno));
90 return -1; 92 return -1;
91 } 93 }
92 if (!WriteFully(fd, buff, len)) { 94 ret = TEMP_FAILURE_RETRY(write(fd, buff, len));
95 if (ret != (ssize_t)len) {
93 QEMU_PIPE_DEBUG("Can't write qemud frame payload: %s", strerror(errno)); 96 QEMU_PIPE_DEBUG("Can't write qemud frame payload: %s", strerror(errno));
94 return -1; 97 return -1;
95 } 98 }
@@ -103,7 +106,8 @@ int qemu_pipe_frame_send(int fd, const void* buff, size_t len) {
103// end-of-stream. 106// end-of-stream.
104int qemu_pipe_frame_recv(int fd, void* buff, size_t len) { 107int qemu_pipe_frame_recv(int fd, void* buff, size_t len) {
105 char header[5]; 108 char header[5];
106 if (!ReadFully(fd, header, 4)) { 109 ssize_t ret = TEMP_FAILURE_RETRY(read(fd, header, 4));
110 if (ret != 4) {
107 QEMU_PIPE_DEBUG("Can't read qemud frame header: %s", strerror(errno)); 111 QEMU_PIPE_DEBUG("Can't read qemud frame header: %s", strerror(errno));
108 return -1; 112 return -1;
109 } 113 }
@@ -118,7 +122,8 @@ int qemu_pipe_frame_recv(int fd, void* buff, size_t len) {
118 len); 122 len);
119 return -1; 123 return -1;
120 } 124 }
121 if (!ReadFully(fd, buff, size)) { 125 ret = TEMP_FAILURE_RETRY(read(fd, buff, size));
126 if (ret != (ssize_t)size) {
122 QEMU_PIPE_DEBUG("Could not read qemud frame payload: %s", 127 QEMU_PIPE_DEBUG("Could not read qemud frame payload: %s",
123 strerror(errno)); 128 strerror(errno));
124 return -1; 129 return -1;