author | Masatoshi Kimura <VYV03354@nifty.ne.jp> |
Tue, 18 Feb 2020 14:24:36 +0000 | |
changeset 514509 | 5ed69fa21d4a3d018438dc934cd60f3caee73e46 |
parent 514508 | 09c9932763ad27dd997888dbd763f757b8217423 |
child 514510 | 31bc0ae892778b5c8e1f100bd8a7f2c59adf7811 |
push id | 37136 |
push user | opoprus@mozilla.com |
push date | Wed, 19 Feb 2020 04:34:03 +0000 |
treeherder | mozilla-central@28cf163158a6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | froydnj |
bugs | 1615900 |
milestone | 75.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
netwerk/socket/nsNamedPipeIOLayer.cpp | file | annotate | diff | comparison | revisions | |
netwerk/test/TestNamedPipeService.cpp | file | annotate | diff | comparison | revisions |
--- a/netwerk/socket/nsNamedPipeIOLayer.cpp +++ b/netwerk/socket/nsNamedPipeIOLayer.cpp @@ -11,16 +11,17 @@ #include "mozilla/Atomics.h" #include "mozilla/DebugOnly.h" #include "mozilla/Logging.h" #include "mozilla/RefPtr.h" #include "mozilla/Unused.h" #include "mozilla/net/DNS.h" #include "nsISupportsImpl.h" #include "nsNamedPipeService.h" +#include "nsNativeCharsetUtils.h" #include "nsNetCID.h" #include "nsServiceManagerUtils.h" #include "nsSocketTransportService2.h" #include "nsString.h" #include "nsThreadUtils.h" #include "nspr.h" #include "private/pprio.h" @@ -38,17 +39,17 @@ static PRIOMethods nsNamedPipeLayerMetho class NamedPipeInfo final : public nsINamedPipeDataObserver { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSINAMEDPIPEDATAOBSERVER explicit NamedPipeInfo(); - nsresult Connect(const nsACString& aPath); + nsresult Connect(const nsAString& aPath); nsresult Disconnect(); /** * Both blocking/non-blocking mode are supported in this class. * The default mode is non-blocking mode, however, the client may change its * mode to blocking mode during hand-shaking (e.g. nsSOCKSSocketInfo). * * In non-blocking mode, |Read| and |Write| should be called by clients only @@ -227,25 +228,23 @@ NamedPipeInfo::OnError(uint32_t aError, NS_NewRunnableFunction("NamedPipeInfo::OnError", [] {}), NS_DISPATCH_NORMAL); return NS_OK; } // Named pipe operations -nsresult NamedPipeInfo::Connect(const nsACString& aPath) { +nsresult NamedPipeInfo::Connect(const nsAString& aPath) { MOZ_ASSERT(OnSocketThread(), "not on socket thread"); - HANDLE pipe; - nsAutoCString path(aPath); - - pipe = CreateFileA(path.get(), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, nullptr); + HANDLE pipe = + CreateFileW(PromiseFlatString(aPath).get(), GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, nullptr); if (pipe == INVALID_HANDLE_VALUE) { LOG_NPIO_ERROR("[%p] CreateFile error (%d)", this, GetLastError()); return NS_ERROR_FAILURE; } DWORD pipeMode = PIPE_READMODE_MESSAGE; if (!SetNamedPipeHandleState(pipe, &pipeMode, nullptr, nullptr)) { @@ -616,18 +615,23 @@ static PRStatus nsNamedPipeConnect(PRFil MOZ_ASSERT(OnSocketThread(), "not on socket thread"); NamedPipeInfo* info = GetNamedPipeInfo(aFd); if (!info) { PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0); return PR_FAILURE; } - if (NS_WARN_IF( - NS_FAILED(info->Connect(nsDependentCString(aAddr->local.path))))) { + nsAutoString path; + if (NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(aAddr->local.path), + path))) { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return PR_FAILURE; + } + if (NS_WARN_IF(NS_FAILED(info->Connect(path)))) { return PR_FAILURE; } return PR_SUCCESS; } static PRStatus nsNamedPipeConnectContinue(PRFileDesc* aFd, PRInt16 aOutFlags) { MOZ_ASSERT(OnSocketThread(), "not on socket thread");
--- a/netwerk/test/TestNamedPipeService.cpp +++ b/netwerk/test/TestNamedPipeService.cpp @@ -8,17 +8,17 @@ #include <windows.h> #include "mozilla/Atomics.h" #include "mozilla/Monitor.h" #include "nsNamedPipeService.h" #include "nsNetCID.h" -#define PIPE_NAME "\\\\.\\pipe\\TestNPS" +#define PIPE_NAME L"\\\\.\\pipe\\TestNPS" #define TEST_STR "Hello World" using namespace mozilla; /** * Unlike a monitor, an event allows a thread to wait on another thread * completing an action without regard to ordering of the wait and the notify. */ @@ -178,17 +178,17 @@ nsNamedPipeDataObserver::OnError(uint32_ } BOOL CreateAndConnectInstance(LPOVERLAPPED aOverlapped, LPHANDLE aPipe); BOOL ConnectToNewClient(HANDLE aPipe, LPOVERLAPPED aOverlapped); BOOL CreateAndConnectInstance(LPOVERLAPPED aOverlapped, LPHANDLE aPipe) { // FIXME: adjust parameters *aPipe = - CreateNamedPipeA(PIPE_NAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, + CreateNamedPipeW(PIPE_NAME, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, 65536, 65536, 3000, NULL); if (*aPipe == INVALID_HANDLE_VALUE) { ADD_FAILURE() << "CreateNamedPipe failed " << GetLastError(); return FALSE; } @@ -223,17 +223,17 @@ static nsresult CreateNamedPipe(LPHANDLE BOOL ret; ret = CreateAndConnectInstance(&overlapped, aServer); if (!ret) { ADD_FAILURE() << "pipe server should be pending"; return NS_ERROR_FAILURE; } - *aClient = CreateFileA(PIPE_NAME, GENERIC_READ | GENERIC_WRITE, + *aClient = CreateFileW(PIPE_NAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); if (*aClient == INVALID_HANDLE_VALUE) { ADD_FAILURE() << "Unable to create pipe client"; CloseHandle(*aServer); return NS_ERROR_FAILURE; }