summaryrefslogtreecommitdiffstats
path: root/adb/adb.c
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-02-24 21:26:58 -0800
committerDan Albert <danalbert@google.com>2015-02-25 15:07:57 -0800
commitcc731cc76786b6bdc58764aad9924c0d0c8d645f (patch)
tree57906636c803e1ae089c2fcf2905d82488b0ba72 /adb/adb.c
parenta035d5003ea593322ba565df9a4f4d0dd6647acf (diff)
downloadsystem_core-cc731cc76786b6bdc58764aad9924c0d0c8d645f.zip
system_core-cc731cc76786b6bdc58764aad9924c0d0c8d645f.tar.gz
system_core-cc731cc76786b6bdc58764aad9924c0d0c8d645f.tar.bz2
Test readx/writex (now renamed).
Renamed readx/writex to ReadFdExactly/WriteFdExactly respectively. These read/write a full fixed-size buffer. If the whole buffer cannot be read/written, these functions return an error. Rename write_string to WriteStringFully. Move the TEMP_FAILURE_RETRY definition in sysdeps.h out of the !Windows section. It seems Windows won't actually interrupt a call, but it's easier to just define it than to #ifdef each call. Change-Id: Ia8ddffa2a52764a2f9a281c96c937660e002b9b9
Diffstat (limited to 'adb/adb.c')
-rw-r--r--adb/adb.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 9c0bd8c..5f244a5 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -30,6 +30,7 @@
#include "sysdeps.h"
#include "adb.h"
#include "adb_auth.h"
+#include "adb_io.h"
#include "adb_listeners.h"
#include "transport.h"
@@ -263,8 +264,8 @@ static void send_msg_with_header(int fd, const char* msg, size_t msglen) {
if (msglen > 0xffff)
msglen = 0xffff;
snprintf(header, sizeof(header), "%04x", (unsigned)msglen);
- writex(fd, header, 4);
- writex(fd, msg, msglen);
+ WriteFdExactly(fd, header, 4);
+ WriteFdExactly(fd, msg, msglen);
}
#endif
@@ -274,8 +275,8 @@ static void send_msg_with_okay(int fd, const char* msg, size_t msglen) {
if (msglen > 0xffff)
msglen = 0xffff;
snprintf(header, sizeof(header), "OKAY%04x", (unsigned)msglen);
- writex(fd, header, 8);
- writex(fd, msg, msglen);
+ WriteFdExactly(fd, header, 8);
+ WriteFdExactly(fd, msg, msglen);
}
#endif // ADB_HOST
@@ -790,9 +791,9 @@ int handle_forward_request(const char* service, transport_type ttype, char* seri
if(r == 0) {
#if ADB_HOST
/* On the host: 1st OKAY is connect, 2nd OKAY is status */
- writex(reply_fd, "OKAY", 4);
+ WriteFdExactly(reply_fd, "OKAY", 4);
#endif
- writex(reply_fd, "OKAY", 4);
+ WriteFdExactly(reply_fd, "OKAY", 4);
return 1;
}