Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
The "problem" I have with this is that (IIRC) retrying close(2) on EINTR is the *wrong* thing to do on linux (because the fd will be closed anyway, and so we may end up closing someone else's file the second time around). I'll try to dig up more info about that tomorrow.
Just found http://alobbs.com/post/54503240599/close-and-eintr and indeed you're right. While I find that behavior really silly and would consider it a bug, I see that POSIX considers it 'undefined' whether the file is closed or not. I guess I'll have to be more careful when deciding which syscalls to wrap.
Hmm, I also see that LLVM has signal-safe Process::SafelyCloseFileDescriptor(). Should I use that, or just ignore potential issues with close()?
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | ||
---|---|---|
255–258 ↗ | (On Diff #191641) | IIUC, these only manipulate the options struct, so I don't see how they could fail with EINTR. OTOH, the tcsetattr call below is documented to return EINTR at least on NetBSD http://netbsd.gw.com/cgi-bin/man-cgi?cfsetospeed+3+NetBSD-current. |
lldb/tools/debugserver/source/DNB.cpp | ||
173 ↗ | (On Diff #191641) | You can't use llvm code from debugserver. I am not really sure what darwin-debug is, but the same may be true for that as well. If I were you, I'd just leave these two alone. |
lldb/tools/lldb-server/lldb-platform.cpp | ||
319 ↗ | (On Diff #191641) | I don't think this is necessary here with WNOHANG and everything. |
I think this is fine, except for the things I pointed out inline. As for SafelyCloseFileDescriptor (wow) thing, I think we should use that, given that it's already there. I suggest making a separate patch for that.
Thanks for the review. Addressed comments.
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | ||
---|---|---|
255–258 ↗ | (On Diff #191641) | Yeah, that's why I covered it, though it looks surprising to me as well. But looking at the code, it can't happen really, so I'll just revert this. |
lldb/tools/lldb-server/lldb-platform.cpp | ||
319 ↗ | (On Diff #191641) | Yep, sorry, missed this one. |
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | ||
---|---|---|
255–258 ↗ | (On Diff #191641) | I think we misunderstood each other. My expectation would be that these two calls don't need EINTR protection, but the tcsetattr call (line 267) does. |
lldb/tools/lldb-server/lldb-platform.cpp | ||
22 ↗ | (On Diff #191644) | revert this part too? |
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | ||
---|---|---|
255–258 ↗ | (On Diff #191641) | I'm not sure if it can happen with TCSANOW but I guess better safe than sorry. |
Now, the curious thing is that so far I have 2 more test failures with this. I'll investigate closer, maybe it's just flakiness.
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp | ||
---|---|---|
255–258 ↗ | (On Diff #191641) | Ah, OK, I see. I am not really familiar with this syscall, so if you are reasonably confident that this particular combo of arguments cannot block (and be interrupted), then I'm fine with leaving the EINTR loop out. |