summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/windows/PipeWindows.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-02-11 18:21:28 +0000
committerZachary Turner <zturner@google.com>2015-02-11 18:21:28 +0000
commitaa60e3c886a95c3909af410e6f2644278aaf502c (patch)
treeab3bbd9492b76ba4975120170544dc9a505339c8 /lldb/source/Host/windows/PipeWindows.cpp
parent05c25c267955da553b7b255cb742b450974e1053 (diff)
downloadbcm5719-llvm-aa60e3c886a95c3909af410e6f2644278aaf502c.tar.gz
bcm5719-llvm-aa60e3c886a95c3909af410e6f2644278aaf502c.zip
Make PipeWindows::CreateWithUniqueName() use GUIDs on Windows.
Patch by Adrian McCarthy Differential Revision: http://reviews.llvm.org/D7509 llvm-svn: 228859
Diffstat (limited to 'lldb/source/Host/windows/PipeWindows.cpp')
-rw-r--r--lldb/source/Host/windows/PipeWindows.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lldb/source/Host/windows/PipeWindows.cpp b/lldb/source/Host/windows/PipeWindows.cpp
index eccc73810f3..3f20cc50285 100644
--- a/lldb/source/Host/windows/PipeWindows.cpp
+++ b/lldb/source/Host/windows/PipeWindows.cpp
@@ -15,6 +15,7 @@
#include <fcntl.h>
#include <io.h>
+#include <rpc.h>
#include <atomic>
#include <string>
@@ -96,14 +97,23 @@ PipeWindows::CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inh
{
llvm::SmallString<128> pipe_name;
Error error;
- do {
+ ::UUID unique_id;
+ RPC_CSTR unique_string;
+ RPC_STATUS status = ::UuidCreate(&unique_id);
+ if (status == RPC_S_OK || status == RPC_S_UUID_LOCAL_ONLY)
+ status = ::UuidToStringA(&unique_id, &unique_string);
+ if (status == RPC_S_OK)
+ {
pipe_name = prefix;
pipe_name += "-";
- for (unsigned i = 0; i < 6; i++) {
- pipe_name += "0123456789abcdef"[llvm::sys::Process::GetRandomNumber() & 15];
- }
- Error error = CreateNew(pipe_name, child_process_inherit);
- } while (error.GetError() == ERROR_ALREADY_EXISTS);
+ pipe_name += reinterpret_cast<char *>(unique_string);
+ ::RpcStringFreeA(&unique_string);
+ error = CreateNew(pipe_name, child_process_inherit);
+ }
+ else
+ {
+ error.SetError(status, eErrorTypeWin32);
+ }
if (error.Success())
name = pipe_name;
return error;
OpenPOWER on IntegriCloud