[Lldb-commits] [PATCH] D131294: [LLDB][NFC] Reliability fixes to TCPSocket code
Slava Gurevich via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Aug 6 23:07:22 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa4977f2e135: [LLDB][NFC] Reliability fixes to TCPSocket code (authored by fixathon).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131294/new/
https://reviews.llvm.org/D131294
Files:
lldb/source/Host/common/TCPSocket.cpp
Index: lldb/source/Host/common/TCPSocket.cpp
===================================================================
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -174,7 +174,10 @@
continue;
}
- SetOptionNoDelay();
+ if (-1 == SetOptionNoDelay()) {
+ Close();
+ continue;
+ }
error.Clear();
return error;
@@ -200,15 +203,18 @@
for (SocketAddress &address : addresses) {
int fd = Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP,
m_child_processes_inherit, error);
- if (error.Fail())
+ if (error.Fail() || fd < 0)
continue;
// enable local address reuse
int option_value = 1;
set_socket_option_arg_type option_value_p =
reinterpret_cast<set_socket_option_arg_type>(&option_value);
- ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
- sizeof(option_value));
+ if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value))) {
+ CLOSE_SOCKET(fd);
+ continue;
+ }
SocketAddress listen_address = address;
if(!listen_address.IsLocalhost())
@@ -255,8 +261,8 @@
return error;
}
- int sock = -1;
- int listen_sock = -1;
+ int sock = kInvalidSocketValue;
+ int listen_sock = kInvalidSocketValue;
lldb_private::SocketAddress AcceptAddr;
MainLoop accept_loop;
std::vector<MainLoopBase::ReadHandleUP> handles;
@@ -288,7 +294,10 @@
lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
- CLOSE_SOCKET(sock);
+ if (kInvalidSocketValue != sock) {
+ CLOSE_SOCKET(sock);
+ sock = kInvalidSocketValue;
+ }
llvm::errs() << llvm::formatv(
"error: rejecting incoming connection from {0} (expecting {1})",
AcceptAddr.GetIPAddress(), AddrIn.GetIPAddress());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131294.450598.patch
Type: text/x-patch
Size: 1983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220807/a7cc268c/attachment.bin>
More information about the lldb-commits
mailing list