summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-02-08 17:25:40 -0800
committerGarrett D'Amore <garrett@damore.org>2018-02-08 18:54:25 -0800
commit092d72d418cea0b7d881e44af7e10b911b1d574b (patch)
tree6c9a4b3a55adfea2ef0a14848f4677a501c9985d
parentd606317f5c028fa8fba5d5384b0ccd90ffa4eab5 (diff)
downloadnng-092d72d418cea0b7d881e44af7e10b911b1d574b.tar.gz
nng-092d72d418cea0b7d881e44af7e10b911b1d574b.tar.bz2
nng-092d72d418cea0b7d881e44af7e10b911b1d574b.zip
Backout #224 Does not work in CI, and breaks legacy compatibility.
It turns out that at least on some systems, the CreateNamedPipeW does not behave as we'd expect. Furthermore, using the Unicode variants seems have a negative impact on compatibility with legacy nanomsg.
-rw-r--r--src/platform/windows/win_ipc.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/platform/windows/win_ipc.c b/src/platform/windows/win_ipc.c
index 9851af25..afa1804e 100644
--- a/src/platform/windows/win_ipc.c
+++ b/src/platform/windows/win_ipc.c
@@ -21,7 +21,7 @@ struct nni_plat_ipc_pipe {
};
struct nni_plat_ipc_ep {
- WCHAR wpath[NNG_MAXADDRLEN + 16];
+ char path[NNG_MAXADDRLEN + 16];
nni_sockaddr addr;
int mode;
int started;
@@ -192,8 +192,6 @@ nni_plat_ipc_ep_init(nni_plat_ipc_ep **epp, const nni_sockaddr *sa, int mode)
{
const char * path;
nni_plat_ipc_ep *ep;
- char scratch[NNG_MAXADDRLEN + 16];
- int rv;
path = sa->s_un.s_path.sa_path;
if (nni_strnlen(path, NNG_MAXADDRLEN) >= NNG_MAXADDRLEN) {
@@ -209,14 +207,7 @@ nni_plat_ipc_ep_init(nni_plat_ipc_ep **epp, const nni_sockaddr *sa, int mode)
NNI_LIST_NODE_INIT(&ep->node);
ep->addr = *sa;
- (void) snprintf(scratch, sizeof(scratch), "\\\\.\\pipe\\%s", path);
- rv = MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, scratch, -1,
- ep->wpath, NNI_NUM_ELEMENTS(ep->wpath));
- if (rv == 0) {
- rv = nni_win_error(GetLastError());
- NNI_FREE_STRUCT(ep);
- return (rv);
- }
+ (void) snprintf(ep->path, sizeof(ep->path), "\\\\.\\pipe\\%s", path);
*epp = ep;
return (0);
@@ -237,7 +228,7 @@ nni_plat_ipc_ep_listen(nni_plat_ipc_ep *ep)
// We create the first named pipe, and we make sure that it is
// properly ours.
- p = CreateNamedPipeW(ep->wpath,
+ p = CreateNamedPipeA(ep->path,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
FILE_FLAG_FIRST_PIPE_INSTANCE,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT |
@@ -286,7 +277,7 @@ nni_win_ipc_acc_finish(nni_win_event *evt, nni_aio *aio)
return;
}
- newp = CreateNamedPipeW(ep->wpath,
+ newp = CreateNamedPipeA(ep->path,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT |
PIPE_REJECT_REMOTE_CLIENTS,
@@ -421,9 +412,9 @@ nni_win_ipc_conn_thr(void *arg)
pipe = NULL;
- p = CreateFileW(ep->wpath,
- GENERIC_READ | GENERIC_WRITE, 0, NULL,
- OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ p = CreateFileA(ep->path, GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED,
+ NULL);
if (p == INVALID_HANDLE_VALUE) {
switch ((rv = GetLastError())) {