From 08f66bc771ac798d89451a9b68a1c6722352d683 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 19 Mar 2015 18:09:59 -0700 Subject: [PATCH] The generic failure case disappeared... Was manifesting as a write to a full disk hanging indefinitely. Bug: 19846181 Change-Id: Ia581e0bbbb331c221bdb68882c238d0cb9f8a0b3 --- adb/adb_io.cpp | 2 ++ adb/adb_io_test.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp index 4dd9f4d02..1a746884b 100644 --- a/adb/adb_io.cpp +++ b/adb/adb_io.cpp @@ -79,6 +79,8 @@ bool WriteFdExactly(int fd, const void* buf, size_t len) { D("writex: fd=%d disconnected\n", fd); errno = 0; return false; + } else { + return false; } } else { len -= r; diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp index 0c69bc94b..da340b237 100644 --- a/adb/adb_io_test.cpp +++ b/adb/adb_io_test.cpp @@ -18,8 +18,11 @@ #include +#include #include #include +#include +#include #include #include @@ -127,6 +130,15 @@ TEST(io, WriteFdExactly_partial) { EXPECT_EQ(expected, s); } +TEST(io, WriteFdExactly_ENOSPC) { + int fd = open("/dev/full", O_WRONLY); + ASSERT_NE(-1, fd); + + char buf[] = "foo"; + ASSERT_FALSE(WriteFdExactly(fd, buf, sizeof(buf))); + ASSERT_EQ(ENOSPC, errno); +} + TEST(io, WriteStringFully) { const char str[] = "Foobar"; TemporaryFile tf;