summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-07-03 09:25:55 +0000
committerPavel Labath <labath@google.com>2017-07-03 09:25:55 +0000
commitc1a6b128c710b2cde0bad5033052aa737291635e (patch)
tree48286437326a2b50084a49759a34663ffffabeda /lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
parentc5e54ddab31ca40a93e61f277d2bbd349fb84f3e (diff)
downloadbcm5719-llvm-c1a6b128c710b2cde0bad5033052aa737291635e.tar.gz
bcm5719-llvm-c1a6b128c710b2cde0bad5033052aa737291635e.zip
Use llvm::sys::RetryAfterSignal instead of a manual while errno!=EINTR loop
Reviewers: zturner, eugene, krytarowski Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D33831 llvm-svn: 307009
Diffstat (limited to 'lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp')
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 6b0f069c35a..105ef0f23d4 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -245,11 +245,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
} else if ((addr = GetURLAddress(path, FILE_SCHEME))) {
std::string addr_str = addr->str();
// file:///PATH
- int fd = -1;
- do {
- fd = ::open(addr_str.c_str(), O_RDWR);
- } while (fd == -1 && errno == EINTR);
-
+ int fd = llvm::sys::RetryAfterSignal(-1, ::open, addr_str.c_str(), O_RDWR);
if (fd == -1) {
if (error_ptr)
error_ptr->SetErrorToErrno();
@@ -620,20 +616,17 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout<std::micro> &timeout,
if (select_helper.FDIsSetRead(pipe_fd)) {
// There is an interrupt or exit command in the command pipe
// Read the data from that pipe:
- char buffer[1];
-
- ssize_t bytes_read;
-
- do {
- bytes_read = ::read(pipe_fd, buffer, sizeof(buffer));
- } while (bytes_read < 0 && errno == EINTR);
+ char c;
- switch (buffer[0]) {
+ ssize_t bytes_read = llvm::sys::RetryAfterSignal(-1, ::read, pipe_fd, &c, 1);
+ assert(bytes_read == 1);
+ (void)bytes_read;
+ switch (c) {
case 'q':
if (log)
log->Printf("%p ConnectionFileDescriptor::BytesAvailable() "
"got data: %c from the command channel.",
- static_cast<void *>(this), buffer[0]);
+ static_cast<void *>(this), c);
return eConnectionStatusEndOfFile;
case 'i':
// Interrupt the current read
OpenPOWER on IntegriCloud