summaryrefslogtreecommitdiff
path: root/src/aio
diff options
context:
space:
mode:
authorTimothee 'TTimo' Besset <ttimo@ttimo.net>2014-09-16 09:10:17 -0500
committerGarrett D'Amore <garrett@damore.org>2015-12-09 12:49:56 -0800
commitc621fb490699dbae8594135f324edb13fb8dc64d (patch)
tree0df19a850bfa9e5b5ac9ba7d6594903bbcc6cb14 /src/aio
parentc0e92dd84f0263fb4f2ad504dd7ccbdf42a24c21 (diff)
downloadnanomsg-c621fb490699dbae8594135f324edb13fb8dc64d.tar.gz
fixes #556 Support security attributes for Windows IPC
Allow passing security descriptor to the ipc channel in Windows. The tunables NN_IPC_SEC_ATTR, as well as NN_IPC_OUTBUFSZ and NN_IPC_INBUFSZ are exposed on Windows when using the named pipe based IPC.
Diffstat (limited to 'src/aio')
-rw-r--r--src/aio/usock_win.h7
-rw-r--r--src/aio/usock_win.inc17
2 files changed, 16 insertions, 8 deletions
diff --git a/src/aio/usock_win.h b/src/aio/usock_win.h
index 615831b..e44576d 100644
--- a/src/aio/usock_win.h
+++ b/src/aio/usock_win.h
@@ -75,6 +75,13 @@ struct nn_usock {
/* For now we allocate a new buffer for each write to a named pipe. */
void *pipesendbuf;
+ /* Pointer to the security attribute structure */
+ SECURITY_ATTRIBUTES *sec_attr;
+
+ /* Out Buffer and In Buffer size */
+ int outbuffersz;
+ int inbuffersz;
+
/* Errno remembered in NN_USOCK_ERROR state */
int errnum;
};
diff --git a/src/aio/usock_win.inc b/src/aio/usock_win.inc
index 5eedfb6..6cc9b24 100644
--- a/src/aio/usock_win.inc
+++ b/src/aio/usock_win.inc
@@ -93,6 +93,11 @@ void nn_usock_init (struct nn_usock *self, int src, struct nn_fsm *owner)
/* NamedPipe-related stuff. */
memset (&self->pipename, 0, sizeof (self->pipename));
self->pipesendbuf = NULL;
+ memset (&self->sec_attr, 0, sizeof (SECURITY_ATTRIBUTES));
+
+ /* default size for both in and out buffers is 4096 */
+ self->outbuffersz = 4096;
+ self->inbuffersz = 4096;
}
void nn_usock_term (struct nn_usock *self)
@@ -501,22 +506,19 @@ static void nn_usock_create_io_completion (struct nn_usock *self)
static void nn_usock_create_pipe (struct nn_usock *self, const char *name)
{
char fullname [256];
-
/* First, create a fully qualified name for the named pipe. */
_snprintf(fullname, sizeof (fullname), "\\\\.\\pipe\\%s", name);
- /* TODO: Expose custom nOutBufferSize, nInBufferSize, nDefaultTimeOut,
- lpSecurityAttributes */
self->p = CreateNamedPipeA (
(char*) fullname,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE |
PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
PIPE_UNLIMITED_INSTANCES,
- 4096,
- 4096,
+ self->outbuffersz,
+ self->inbuffersz,
0,
- NULL);
+ self->sec_attr);
/* TODO: How to properly handle self->p == INVALID_HANDLE_VALUE? */
win_assert (self->p != INVALID_HANDLE_VALUE);
@@ -535,12 +537,11 @@ DWORD nn_usock_open_pipe (struct nn_usock *self, const char *name)
/* First, create a fully qualified name for the named pipe. */
_snprintf(fullname, sizeof (fullname), "\\\\.\\pipe\\%s", name);
- /* TODO: Expose a way to pass lpSecurityAttributes */
self->p = CreateFileA (
fullname,
GENERIC_READ | GENERIC_WRITE,
0,
- NULL,
+ self->sec_attr,
OPEN_ALWAYS,
FILE_FLAG_OVERLAPPED,
NULL);