krytarowski created this revision.
krytarowski added reviewers: labath, joerg.
krytarowski added a project: LLDB.
Herald added a subscriber: llvm-commits.

Reset errno to 0 for error branches.

Without this, debugging real issues in LLDB is harder
as we don't know what and when caused the errno
to be set.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D43698

Files:
  source/Host/common/TCPSocket.cpp


Index: source/Host/common/TCPSocket.cpp
===================================================================
--- source/Host/common/TCPSocket.cpp
+++ source/Host/common/TCPSocket.cpp
@@ -146,14 +146,17 @@
       host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (auto address : addresses) {
     error = CreateSocket(address.GetFamily());
-    if (error.Fail())
+    if (error.Fail()) {
+      errno = 0;
       continue;
+    }
 
     address.SetPort(port);
 
     if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(),
                         address.GetLength())) {
       CLOSE_SOCKET(GetNativeSocket());
+      errno = 0;
       continue;
     }
 


Index: source/Host/common/TCPSocket.cpp
===================================================================
--- source/Host/common/TCPSocket.cpp
+++ source/Host/common/TCPSocket.cpp
@@ -146,14 +146,17 @@
       host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (auto address : addresses) {
     error = CreateSocket(address.GetFamily());
-    if (error.Fail())
+    if (error.Fail()) {
+      errno = 0;
       continue;
+    }
 
     address.SetPort(port);
 
     if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(),
                         address.GetLength())) {
       CLOSE_SOCKET(GetNativeSocket());
+      errno = 0;
       continue;
     }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to