diff options
Diffstat (limited to 'source/Host/common/Socket.cpp')
| -rw-r--r-- | source/Host/common/Socket.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp index 79777c88fa46..2a665ddacb64 100644 --- a/source/Host/common/Socket.cpp +++ b/source/Host/common/Socket.cpp @@ -9,14 +9,14 @@ #include "lldb/Host/Socket.h" -#include "lldb/Core/Log.h" -#include "lldb/Core/RegularExpression.h" #include "lldb/Host/Config.h" #include "lldb/Host/Host.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Host/StringConvert.h" #include "lldb/Host/common/TCPSocket.h" #include "lldb/Host/common/UDPSocket.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/RegularExpression.h" #ifndef LLDB_DISABLE_POSIX #include "lldb/Host/posix/DomainSocket.h" @@ -38,11 +38,9 @@ #include <asm-generic/errno-base.h> #include <errno.h> #include <linux/tcp.h> -#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC) #include <fcntl.h> #include <sys/syscall.h> #include <unistd.h> -#endif // ANDROID_ARM_BUILD_STATIC || ANDROID_MIPS_BUILD_STATIC #endif // __ANDROID__ using namespace lldb; @@ -174,15 +172,13 @@ Error Socket::TcpListen(llvm::StringRef host_and_port, } Error Socket::UdpConnect(llvm::StringRef host_and_port, - bool child_processes_inherit, Socket *&send_socket, - Socket *&recv_socket) { + bool child_processes_inherit, Socket *&socket) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("Socket::%s (host/port = %s)", __FUNCTION__, host_and_port.data()); - return UDPSocket::Connect(host_and_port, child_processes_inherit, send_socket, - recv_socket); + return UDPSocket::Connect(host_and_port, child_processes_inherit, socket); } Error Socket::UnixDomainConnect(llvm::StringRef name, @@ -424,9 +420,13 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, socklen_t *addrlen, bool child_processes_inherit, Error &error) { error.Clear(); -#if defined(ANDROID_ARM_BUILD_STATIC) || defined(ANDROID_MIPS_BUILD_STATIC) - // Temporary workaround for statically linking Android lldb-server with the - // latest API. +#if defined(ANDROID_USE_ACCEPT_WORKAROUND) + // Hack: + // This enables static linking lldb-server to an API 21 libc, but still having + // it run on older devices. It is necessary because API 21 libc's + // implementation of accept() uses the accept4 syscall(), which is not + // available in older kernels. Using an older libc would fix this issue, but + // introduce other ones, as the old libraries were quite buggy. int fd = syscall(__NR_accept, sockfd, addr, addrlen); if (fd >= 0 && !child_processes_inherit) { int flags = ::fcntl(fd, F_GETFD); @@ -441,11 +441,7 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr, if (!child_processes_inherit) { flags |= SOCK_CLOEXEC; } -#if defined(__NetBSD__) - NativeSocket fd = ::paccept(sockfd, addr, addrlen, nullptr, flags); -#else NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags); -#endif #else NativeSocket fd = ::accept(sockfd, addr, addrlen); #endif |
