This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [Core] Harmonize Communication::Read() returns w/ thread
ClosedPublic

Authored by mgorny on Aug 19 2022, 3:39 AM.

Details

Summary

Harmonize the status and error values of Communication::Read() when
running with and without read thread. Prior to this change, Read()
would return eConnectionStatusSuccess if read thread was enabled
and the read timed out or reached end-of-file, rather than
the respective states that are returned if read thread was disabled.
Now, it correctly returns eConnectionStatusTimedOut
and eConnectionStatusEndOfFile, and sets the error respectively.

Sponsored by: The FreeBSD Foundation

Diff Detail

Event Timeline

mgorny created this revision.Aug 19 2022, 3:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 3:39 AM
mgorny requested review of this revision.Aug 19 2022, 3:39 AM

Cool stuff. Would it be possible to test for the two paths into a single function (with some ifs, if necessary)? That would make it clearer what (if any) are the differences between the two modes of operation.

Cool stuff. Would it be possible to test for the two paths into a single function (with some ifs, if necessary)? That would make it clearer what (if any) are the differences between the two modes of operation.

I suppose this makes sense (why didn't I think of it?!). I was thinking of using parametrized tests but they seemed a bit too complex for two cases.

mgorny updated this revision to Diff 453950.Aug 19 2022, 4:14 AM

Use a common test function.

labath accepted this revision.Aug 19 2022, 4:24 AM
This revision is now accepted and ready to land.Aug 19 2022, 4:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 6:36 AM

@labath, any chance you could take a look at the failures on Windows? I'm wondering if this is because "pipes don't work like that on Windows" or if there's a way to make them work. For now I'm just going to skip these tests on win32.

https://lab.llvm.org/buildbot/#/builders/83/builds/22672

@labath, any chance you could take a look at the failures on Windows? I'm wondering if this is because "pipes don't work like that on Windows" or if there's a way to make them work. For now I'm just going to skip these tests on win32.

https://lab.llvm.org/buildbot/#/builders/83/builds/22672

I'm not sure why the first write fails, but I believe that even if we fixed that, that we would have problems with the read operation, as the pipe FD will not work with select. I think the safest/simplest way to fix this would be to change the test to use sockets instead.