Loading libs/binder/RpcServer.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -49,8 +49,6 @@ bool RpcServer::setupUnixDomainServer(const char* path) { return setupSocketServer(UnixSocketAddress(path)); } #ifdef __BIONIC__ bool RpcServer::setupVsockServer(unsigned int port) { // realizing value w/ this type at compile time to avoid ubsan abort constexpr unsigned int kAnyCid = VMADDR_CID_ANY; Loading @@ -58,8 +56,6 @@ bool RpcServer::setupVsockServer(unsigned int port) { return setupSocketServer(VsockSocketAddress(kAnyCid, port)); } #endif // __BIONIC__ bool RpcServer::setupInetServer(unsigned int port, unsigned int* assignedPort) { const char* kAddr = "127.0.0.1"; Loading libs/binder/RpcSession.cpp +36 −30 Original line number Diff line number Diff line Loading @@ -61,14 +61,10 @@ bool RpcSession::setupUnixDomainClient(const char* path) { return setupSocketClient(UnixSocketAddress(path)); } #ifdef __BIONIC__ bool RpcSession::setupVsockClient(unsigned int cid, unsigned int port) { return setupSocketClient(VsockSocketAddress(cid, port)); } #endif // __BIONIC__ bool RpcSession::setupInetClient(const char* addr, unsigned int port) { auto aiStart = InetSocketAddress::getAddrInfo(addr, port); if (aiStart == nullptr) return false; Loading Loading @@ -219,28 +215,34 @@ bool RpcSession::setupSocketClient(const RpcSocketAddress& addr) { // we've already setup one client for (size_t i = 0; i + 1 < numThreadsAvailable; i++) { // TODO(b/185167543): avoid race w/ accept4 not being called on server for (size_t tries = 0; tries < 5; tries++) { if (setupOneSocketClient(addr, mId.value())) break; usleep(10000); } // TODO(b/185167543): shutdown existing connections? if (!setupOneSocketClient(addr, mId.value())) return false; } return true; } bool RpcSession::setupOneSocketClient(const RpcSocketAddress& addr, int32_t id) { for (size_t tries = 0; tries < 5; tries++) { if (tries > 0) usleep(10000); unique_fd serverFd( TEMP_FAILURE_RETRY(socket(addr.addr()->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0))); if (serverFd == -1) { int savedErrno = errno; ALOGE("Could not create socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); ALOGE("Could not create socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); return false; } if (0 != TEMP_FAILURE_RETRY(connect(serverFd.get(), addr.addr(), addr.addrSize()))) { if (errno == ECONNRESET) { ALOGW("Connection reset on %s", addr.toString().c_str()); continue; } int savedErrno = errno; ALOGE("Could not connect socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); ALOGE("Could not connect socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); return false; } Loading @@ -257,6 +259,10 @@ bool RpcSession::setupOneSocketClient(const RpcSocketAddress& addr, int32_t id) return true; } ALOGE("Ran out of retries to connect to %s", addr.toString().c_str()); return false; } void RpcSession::addClient(unique_fd fd) { std::lock_guard<std::mutex> _l(mMutex); sp<RpcConnection> session = sp<RpcConnection>::make(); Loading libs/binder/RpcSocketAddress.h +1 −7 Original line number Diff line number Diff line Loading @@ -24,9 +24,7 @@ #include <sys/types.h> #include <sys/un.h> #ifdef __BIONIC__ #include <linux/vm_sockets.h> #endif #include "vm_sockets.h" namespace android { Loading Loading @@ -59,8 +57,6 @@ private: sockaddr_un mAddr; }; #ifdef __BIONIC__ class VsockSocketAddress : public RpcSocketAddress { public: VsockSocketAddress(unsigned int cid, unsigned int port) Loading @@ -80,8 +76,6 @@ private: sockaddr_vm mAddr; }; #endif // __BIONIC__ class InetSocketAddress : public RpcSocketAddress { public: InetSocketAddress(const sockaddr* sockAddr, size_t size, const char* addr, unsigned int port) Loading libs/binder/include/binder/RpcServer.h +0 −2 Original line number Diff line number Diff line Loading @@ -57,12 +57,10 @@ public: */ [[nodiscard]] bool setupUnixDomainServer(const char* path); #ifdef __BIONIC__ /** * Creates an RPC server at the current port. */ [[nodiscard]] bool setupVsockServer(unsigned int port); #endif // __BIONIC__ /** * Creates an RPC server at the current port using IPv4. Loading libs/binder/include/binder/RpcSession.h +0 −2 Original line number Diff line number Diff line Loading @@ -52,12 +52,10 @@ public: */ [[nodiscard]] bool setupUnixDomainClient(const char* path); #ifdef __BIONIC__ /** * Connects to an RPC server at the CVD & port. */ [[nodiscard]] bool setupVsockClient(unsigned int cvd, unsigned int port); #endif // __BIONIC__ /** * Connects to an RPC server at the given address and port. Loading Loading
libs/binder/RpcServer.cpp +0 −4 Original line number Diff line number Diff line Loading @@ -49,8 +49,6 @@ bool RpcServer::setupUnixDomainServer(const char* path) { return setupSocketServer(UnixSocketAddress(path)); } #ifdef __BIONIC__ bool RpcServer::setupVsockServer(unsigned int port) { // realizing value w/ this type at compile time to avoid ubsan abort constexpr unsigned int kAnyCid = VMADDR_CID_ANY; Loading @@ -58,8 +56,6 @@ bool RpcServer::setupVsockServer(unsigned int port) { return setupSocketServer(VsockSocketAddress(kAnyCid, port)); } #endif // __BIONIC__ bool RpcServer::setupInetServer(unsigned int port, unsigned int* assignedPort) { const char* kAddr = "127.0.0.1"; Loading
libs/binder/RpcSession.cpp +36 −30 Original line number Diff line number Diff line Loading @@ -61,14 +61,10 @@ bool RpcSession::setupUnixDomainClient(const char* path) { return setupSocketClient(UnixSocketAddress(path)); } #ifdef __BIONIC__ bool RpcSession::setupVsockClient(unsigned int cid, unsigned int port) { return setupSocketClient(VsockSocketAddress(cid, port)); } #endif // __BIONIC__ bool RpcSession::setupInetClient(const char* addr, unsigned int port) { auto aiStart = InetSocketAddress::getAddrInfo(addr, port); if (aiStart == nullptr) return false; Loading Loading @@ -219,28 +215,34 @@ bool RpcSession::setupSocketClient(const RpcSocketAddress& addr) { // we've already setup one client for (size_t i = 0; i + 1 < numThreadsAvailable; i++) { // TODO(b/185167543): avoid race w/ accept4 not being called on server for (size_t tries = 0; tries < 5; tries++) { if (setupOneSocketClient(addr, mId.value())) break; usleep(10000); } // TODO(b/185167543): shutdown existing connections? if (!setupOneSocketClient(addr, mId.value())) return false; } return true; } bool RpcSession::setupOneSocketClient(const RpcSocketAddress& addr, int32_t id) { for (size_t tries = 0; tries < 5; tries++) { if (tries > 0) usleep(10000); unique_fd serverFd( TEMP_FAILURE_RETRY(socket(addr.addr()->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0))); if (serverFd == -1) { int savedErrno = errno; ALOGE("Could not create socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); ALOGE("Could not create socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); return false; } if (0 != TEMP_FAILURE_RETRY(connect(serverFd.get(), addr.addr(), addr.addrSize()))) { if (errno == ECONNRESET) { ALOGW("Connection reset on %s", addr.toString().c_str()); continue; } int savedErrno = errno; ALOGE("Could not connect socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); ALOGE("Could not connect socket at %s: %s", addr.toString().c_str(), strerror(savedErrno)); return false; } Loading @@ -257,6 +259,10 @@ bool RpcSession::setupOneSocketClient(const RpcSocketAddress& addr, int32_t id) return true; } ALOGE("Ran out of retries to connect to %s", addr.toString().c_str()); return false; } void RpcSession::addClient(unique_fd fd) { std::lock_guard<std::mutex> _l(mMutex); sp<RpcConnection> session = sp<RpcConnection>::make(); Loading
libs/binder/RpcSocketAddress.h +1 −7 Original line number Diff line number Diff line Loading @@ -24,9 +24,7 @@ #include <sys/types.h> #include <sys/un.h> #ifdef __BIONIC__ #include <linux/vm_sockets.h> #endif #include "vm_sockets.h" namespace android { Loading Loading @@ -59,8 +57,6 @@ private: sockaddr_un mAddr; }; #ifdef __BIONIC__ class VsockSocketAddress : public RpcSocketAddress { public: VsockSocketAddress(unsigned int cid, unsigned int port) Loading @@ -80,8 +76,6 @@ private: sockaddr_vm mAddr; }; #endif // __BIONIC__ class InetSocketAddress : public RpcSocketAddress { public: InetSocketAddress(const sockaddr* sockAddr, size_t size, const char* addr, unsigned int port) Loading
libs/binder/include/binder/RpcServer.h +0 −2 Original line number Diff line number Diff line Loading @@ -57,12 +57,10 @@ public: */ [[nodiscard]] bool setupUnixDomainServer(const char* path); #ifdef __BIONIC__ /** * Creates an RPC server at the current port. */ [[nodiscard]] bool setupVsockServer(unsigned int port); #endif // __BIONIC__ /** * Creates an RPC server at the current port using IPv4. Loading
libs/binder/include/binder/RpcSession.h +0 −2 Original line number Diff line number Diff line Loading @@ -52,12 +52,10 @@ public: */ [[nodiscard]] bool setupUnixDomainClient(const char* path); #ifdef __BIONIC__ /** * Connects to an RPC server at the CVD & port. */ [[nodiscard]] bool setupVsockClient(unsigned int cvd, unsigned int port); #endif // __BIONIC__ /** * Connects to an RPC server at the given address and port. Loading