diff options
author | 2021-09-17 20:47:42 +0000 | |
---|---|---|
committer | 2021-09-17 20:47:42 +0000 | |
commit | 5c78b18047eb5d8e532f6dfa482b2c0bf8eb96cb (patch) | |
tree | c80c9997ea7de42942dbd9e0842d1e867e90faef | |
parent | c6e856f104d717214c0adbc76c3e45f64e10b061 (diff) | |
parent | bc910fa39c42078d74ca96a7a538ea51aae07cb3 (diff) |
Merge changes I4894c2dd,Id2977f05 am: 22a54f6a5f am: 1cfbd1bce8 am: 8b56fe841b am: ddf8d79986 am: bc910fa39c
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1788928
Change-Id: I8680a7371125355ba758564d0ee3762c67c35100
-rw-r--r-- | libs/binder/FdTrigger.cpp | 2 | ||||
-rw-r--r-- | libs/binder/RpcState.cpp | 8 | ||||
-rw-r--r-- | libs/binder/RpcTransportTls.cpp | 6 | ||||
-rw-r--r-- | libs/binder/tests/binderRpcTest.cpp | 6 |
4 files changed, 12 insertions, 10 deletions
diff --git a/libs/binder/FdTrigger.cpp b/libs/binder/FdTrigger.cpp index ecf13dc583..49f83ff346 100644 --- a/libs/binder/FdTrigger.cpp +++ b/libs/binder/FdTrigger.cpp @@ -53,7 +53,7 @@ status_t FdTrigger::triggerablePoll(base::borrowed_fd fd, int16_t event) { continue; } if (pfd[1].revents & POLLHUP) { - return -ECANCELED; + return DEAD_OBJECT; } return pfd[0].revents & event ? OK : DEAD_OBJECT; } diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 11a083ac11..dcba837a85 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -323,6 +323,7 @@ status_t RpcState::rpcRec(const sp<RpcSession::RpcConnection>& connection, status != OK) { LOG_RPC_DETAIL("Failed to read %s (%zu bytes) on RpcTransport %p, error: %s", what, size, connection->rpcTransport.get(), statusToString(status).c_str()); + (void)session->shutdownAndWait(false); return status; } @@ -531,8 +532,8 @@ status_t RpcState::waitForReply(const sp<RpcSession::RpcConnection>& connection, const sp<RpcSession>& session, Parcel* reply) { RpcWireHeader command; while (true) { - if (status_t status = - rpcRec(connection, session, "command header", &command, sizeof(command)); + if (status_t status = rpcRec(connection, session, "command header (for reply)", &command, + sizeof(command)); status != OK) return status; @@ -601,7 +602,8 @@ status_t RpcState::getAndExecuteCommand(const sp<RpcSession::RpcConnection>& con LOG_RPC_DETAIL("getAndExecuteCommand on RpcTransport %p", connection->rpcTransport.get()); RpcWireHeader command; - if (status_t status = rpcRec(connection, session, "command header", &command, sizeof(command)); + if (status_t status = rpcRec(connection, session, "command header (for server)", &command, + sizeof(command)); status != OK) return status; diff --git a/libs/binder/RpcTransportTls.cpp b/libs/binder/RpcTransportTls.cpp index 23088ad60e..79445d9934 100644 --- a/libs/binder/RpcTransportTls.cpp +++ b/libs/binder/RpcTransportTls.cpp @@ -241,7 +241,7 @@ private: status_t handlePoll(int event, android::base::borrowed_fd fd, FdTrigger* fdTrigger, const char* fnString) { status_t ret = fdTrigger->triggerablePoll(fd, event); - if (ret != OK && ret != DEAD_OBJECT && ret != -ECANCELED) { + if (ret != OK && ret != DEAD_OBJECT) { ALOGE("triggerablePoll error while poll()-ing after %s(): %s", fnString, statusToString(ret).c_str()); } @@ -348,7 +348,7 @@ status_t RpcTransportTls::interruptableWriteFully(FdTrigger* fdTrigger, const vo // Before doing any I/O, check trigger once. This ensures the trigger is checked at least // once. The trigger is also checked via triggerablePoll() after every SSL_write(). - if (fdTrigger->isTriggered()) return -ECANCELED; + if (fdTrigger->isTriggered()) return DEAD_OBJECT; while (buffer < end) { size_t todo = std::min<size_t>(end - buffer, std::numeric_limits<int>::max()); @@ -379,7 +379,7 @@ status_t RpcTransportTls::interruptableReadFully(FdTrigger* fdTrigger, void* dat // Before doing any I/O, check trigger once. This ensures the trigger is checked at least // once. The trigger is also checked via triggerablePoll() after every SSL_write(). - if (fdTrigger->isTriggered()) return -ECANCELED; + if (fdTrigger->isTriggered()) return DEAD_OBJECT; while (buffer < end) { size_t todo = std::min<size_t>(end - buffer, std::numeric_limits<int>::max()); diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 6bcf102694..cc1d2fae56 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -1794,9 +1794,9 @@ TEST_P(RpcTransportTest, Trigger) { } status = serverTransport->interruptableWriteFully(fdTrigger, msg2.data(), msg2.size()); - if (status != -ECANCELED) + if (status != DEAD_OBJECT) return AssertionFailure() << "When FdTrigger is shut down, interruptableWriteFully " - "should return -ECANCELLED, but it is " + "should return DEAD_OBJECT, but it is " << statusToString(status); return AssertionSuccess(); }; @@ -1830,7 +1830,7 @@ TEST_P(RpcTransportTest, Trigger) { } writeCv.notify_all(); // After this line, server thread unblocks and attempts to write the second message, but - // shutdown is triggered, so write should failed with -ECANCELLED. See |serverPostConnect|. + // shutdown is triggered, so write should failed with DEAD_OBJECT. See |serverPostConnect|. // On the client side, second read fails with DEAD_OBJECT ASSERT_FALSE(client.readMessage(msg2)); } |