Extend PipePosix with support for named pipes/timeout-based IO and integrate it with...
authorOleksiy Vyalov <ovyalov@google.com>
Wed, 14 Jan 2015 01:31:27 +0000 (01:31 +0000)
committerOleksiy Vyalov <ovyalov@google.com>
Wed, 14 Jan 2015 01:31:27 +0000 (01:31 +0000)
http://reviews.llvm.org/D6954

llvm-svn: 225923

lldb/include/lldb/Host/PipeBase.h
lldb/include/lldb/Host/posix/PipePosix.h
lldb/include/lldb/Host/windows/PipeWindows.h
lldb/source/Host/common/PipeBase.cpp
lldb/source/Host/posix/PipePosix.cpp
lldb/source/Host/windows/PipeWindows.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

index b22b273..8cad250 100644 (file)
@@ -26,8 +26,7 @@ class PipeBase
     virtual Error CreateNew(bool child_process_inherit) = 0;
     virtual Error CreateNew(llvm::StringRef name, bool child_process_inherit) = 0;
 
-    Error OpenAsReader(llvm::StringRef name, bool child_process_inherit);
-    virtual Error OpenAsReaderWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) = 0;
+    virtual Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) = 0;
 
     Error OpenAsWriter(llvm::StringRef name, bool child_process_inherit);
     virtual Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) = 0;
index 6a29e6f..0ab3ff7 100644 (file)
@@ -36,7 +36,7 @@ public:
     Error
     CreateNew(llvm::StringRef name, bool child_process_inherit) override;
     Error
-    OpenAsReaderWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
+    OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
     Error
     OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
 
index a292392..02b7d47 100644 (file)
@@ -31,7 +31,7 @@ class PipeWindows : public PipeBase
 
     Error CreateNew(bool child_process_inherit) override;
     Error CreateNew(llvm::StringRef name, bool child_process_inherit) override;
-    Error OpenAsReaderWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
+    Error OpenAsReader(llvm::StringRef name, bool child_process_inherit) override;
     Error OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout) override;
 
     bool CanRead() const override;
index 3b1932c..a9d6e6f 100644 (file)
@@ -15,12 +15,6 @@ using namespace lldb_private;
 PipeBase::~PipeBase() = default;
 
 Error
-PipeBase::OpenAsReader(llvm::StringRef name, bool child_process_inherit)
-{
-    return OpenAsReaderWithTimeout(name, child_process_inherit, std::chrono::microseconds::zero());
-}
-
-Error
 PipeBase::OpenAsWriter(llvm::StringRef name, bool child_process_inherit)
 {
     return OpenAsWriterWithTimeout(name, child_process_inherit, std::chrono::microseconds::zero());
index c4706cd..02838ec 100644 (file)
@@ -183,7 +183,7 @@ PipePosix::CreateNew(llvm::StringRef name, bool child_process_inherit)
 }
 
 Error
-PipePosix::OpenAsReaderWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout)
+PipePosix::OpenAsReader(llvm::StringRef name, bool child_process_inherit)
 {
     if (CanRead() || CanWrite())
         return Error("Pipe is already opened");
index ad87b9e..852630e 100644 (file)
@@ -90,7 +90,7 @@ PipeWindows::CreateNew(llvm::StringRef name, bool child_process_inherit)
 }
 
 Error
-PipeWindows::OpenAsReaderWithTimeout(llvm::StringRef name, bool child_process_inherit, const std::chrono::microseconds &timeout)
+PipeWindows::OpenAsReader(llvm::StringRef name, bool child_process_inherit)
 {
     if (CanRead() || CanWrite())
         return Error(ERROR_ALREADY_EXISTS, eErrorTypeWin32);
index 2a944a7..919fa54 100644 (file)
@@ -876,15 +876,14 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *hostname,
         {
             if (named_pipe_path[0])
             {
-                const auto timeout = std::chrono::microseconds(10 * 1000000);
-                error = port_named_pipe.OpenAsReaderWithTimeout(named_pipe_path, false, timeout);
+                error = port_named_pipe.OpenAsReader(named_pipe_path, false);
                 if (error.Success())
                 {
                     char port_cstr[256];
                     port_cstr[0] = '\0';
                     size_t num_bytes = sizeof(port_cstr);
                     // Read port from pipe with 10 second timeout.
-                    error = port_named_pipe.ReadWithTimeout(port_cstr, num_bytes, timeout, num_bytes);
+                    error = port_named_pipe.ReadWithTimeout(port_cstr, num_bytes, std::chrono::microseconds(10 * 1000000), num_bytes);
                     if (error.Success())
                     {
                         assert (num_bytes > 0 && port_cstr[num_bytes-1] == '\0');