summaryrefslogtreecommitdiff
path: root/client/main.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-11-18 18:07:48 -0800
committerElliott Hughes <enh@google.com>2015-11-20 09:42:23 -0800
commite821a5d6eaf21382c4fdd70cf6fc88cf82798939 (patch)
tree7cb1d9432f8d6813df9a986b45f12eb0bab8d7fc /client/main.cpp
parent70cd88a6c63febbfc942d65d851130670092c44a (diff)
downloadadb-e821a5d6eaf21382c4fdd70cf6fc88cf82798939.tar.gz
Avoid SIGPIPE in adb.
We're now able to send packets faster than the device can handle them, meaning that sometimes we're several packets through before the device says "hey, wait, I can't write" and closes the connection. At best this led to us reporting that we couldn't sync because "Connection reset"; at worst we'd get SIGPIPE because we were still streaming to a connection that had already been closed. This change renames adb_main adb_server_main, and moves the ignoring of SIGPIPE into adb_commandline so it applies to both client and server (but not adbd). This change doesn't address the "wrong error message" part of the problem, but at least it means you'll get *an* error message. Bug: http://b/25230872 Change-Id: Ic60e4d13ed03fdcdf0d5cbc97201ebd1097c16ed
Diffstat (limited to 'client/main.cpp')
-rw-r--r--client/main.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/client/main.cpp b/client/main.cpp
index 8d01af3..04b9882 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -86,8 +86,7 @@ static void close_stdin() {
static void setup_daemon_logging(void) {
const std::string log_file_path(GetLogFilePath());
- int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND,
- 0640);
+ int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0640);
if (fd == -1) {
fatal("cannot open '%s': %s", log_file_path.c_str(), strerror(errno));
}
@@ -103,10 +102,10 @@ static void setup_daemon_logging(void) {
LOG(INFO) << adb_version();
}
-int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
+int adb_server_main(int is_daemon, int server_port, int ack_reply_fd) {
#if defined(_WIN32)
// adb start-server starts us up with stdout and stderr hooked up to
- // anonymous pipes to. When the C Runtime sees this, it makes stderr and
+ // anonymous pipes. When the C Runtime sees this, it makes stderr and
// stdout buffered, but to improve the chance that error output is seen,
// unbuffer stdout and stderr just like if we were run at the console.
// This also keeps stderr unbuffered when it is redirected to adb.log.
@@ -120,8 +119,6 @@ int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
}
SetConsoleCtrlHandler(ctrlc_handler, TRUE);
-#else
- signal(SIGPIPE, SIG_IGN);
#endif
init_transport_registration();