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>
Differential D43698
Plug errno in TCPSocket::Connect() krytarowski on Feb 23 2018, 2:48 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions This seems weird. I have never seen anyone resetting errno *after* a call. Wouldn't it be better to log strerror(errno) somewhere, or make sure that the Status object reflects the actual error? Comment Actions Yeah, never seen that before. Are you sure CreateSocket is doing the right thing and checking for the correct return value? That is the only way I can see this causing issues. Comment Actions This just helps debugging connectivity issues in other unrelated code-parts (I'm debugging why select(2) / recv(2) don't receive a packet of type qHostInfo). Floating errno is annoying. TCPSocket::Connect() has no bugs at least I'm not aware of them. Comment Actions https://github.com/search?l=C&q=save_errno&ref=opensearch&type=Code Here is an approach with save_errno, useful in libraries when we preserve errno for public functions in the API of a library as-is, and not leaking it from the internals to unrelated code. Right now I don't volunteer to perform this for LLDB, but it would be nice to not propagate it. Comment Actions Yes, but that's why we have the Error objects, so we don't have to do the errno save-restore dance. If this is just a debugging aid, then maybe you should keep it as such (locally). There are plenty of places that will leave a stray errno around and I don't think we want to do this resetting on all of them. |