Skip to content

Commit

Permalink
Make PipeWindows::CreateWithUniqueName() use GUIDs on Windows.
Browse files Browse the repository at this point in the history
Patch by Adrian McCarthy
Differential Revision: http://reviews.llvm.org/D7509

llvm-svn: 228859
  • Loading branch information
Zachary Turner committed Feb 11, 2015
1 parent 05c25c2 commit aa60e3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions lldb/cmake/LLDBDependencies.cmake
Expand Up @@ -69,6 +69,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
lldbPluginProcessElfCore
lldbPluginJITLoaderGDB
Ws2_32
Rpcrt4
)
endif ()

Expand Down
22 changes: 16 additions & 6 deletions lldb/source/Host/windows/PipeWindows.cpp
Expand Up @@ -15,6 +15,7 @@

#include <fcntl.h>
#include <io.h>
#include <rpc.h>

#include <atomic>
#include <string>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit aa60e3c

Please sign in to comment.