From b9bd6af2f2ffcbd44658a083f6a4096b39a27ca5 Mon Sep 17 00:00:00 2001 From: Vince Harron Date: Mon, 20 Apr 2015 18:15:33 +0000 Subject: [PATCH] ConnectionFileDescriptor::BytesAvailable reading too many command bytes ConnectionFileDescriptor::BytesAvailable was reading multiple command bytes from the command pipe but only processing the first. This change only allows one byte to be read at a time, ensuring that all get handled. This isn't known to cause any bugs, but it might cause current/future bugs. Differential Revision: http://reviews.llvm.org/D9098 llvm-svn: 235322 --- .../Host/posix/ConnectionFileDescriptorPosix.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index 9946cb42663b..8eb848c9481e 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -685,8 +685,10 @@ ConnectionFileDescriptor::BytesAvailable(uint32_t timeout_usec, Error *error_ptr return eConnectionStatusSuccess; if (have_pipe_fd && FD_ISSET(pipe_fd, FD_SET_DATA(read_fds))) { - // We got a command to exit. Read the data from that pipe: - char buffer[16]; + // 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 @@ -698,8 +700,9 @@ ConnectionFileDescriptor::BytesAvailable(uint32_t timeout_usec, Error *error_ptr { case 'q': if (log) - log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.", - static_cast(this), static_cast(bytes_read), buffer); + log->Printf("%p ConnectionFileDescriptor::BytesAvailable() " + "got data: %c from the command channel.", + static_cast(this), buffer[0]); return eConnectionStatusEndOfFile; case 'i': // Interrupt the current read