~RpcServer() calls shutdown explicitly.

If a thread is calling RpcServer::join() and poll()-ing,
when ~RpcServer() is called, the first thing it does
is deleting mJoinShutdownTrigger, which will close the
read end first.

poll(2):
  For a discussion of what may happen if a file descriptor being
  monitored by poll() is closed in another thread, see select(2).

select(2):
  If a file descriptor being monitored by select() is closed in
  another thread, the result is unspecified.

To avoid relying on UB, properly shut down before closing these fds.

Test: binderRpcTest
Test: binderLibTest

Bug: 182914638

Change-Id: Id689fa31e6cbf055f6c60a443e8f4ad0dae7ceb1
diff --git a/libs/binder/RpcServer.cpp b/libs/binder/RpcServer.cpp
index e31aea0..63d4dde 100644
--- a/libs/binder/RpcServer.cpp
+++ b/libs/binder/RpcServer.cpp
@@ -39,7 +39,9 @@
 using base::unique_fd;
 
 RpcServer::RpcServer() {}
-RpcServer::~RpcServer() {}
+RpcServer::~RpcServer() {
+    (void)shutdown();
+}
 
 sp<RpcServer> RpcServer::make() {
     return sp<RpcServer>::make();
@@ -204,7 +206,6 @@
 }
 
 bool RpcServer::shutdown() {
-    LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
     std::unique_lock<std::mutex> _l(mLock);
     if (mShutdownTrigger == nullptr) return false;