WINPR_API char* GetNamedPipeUnixDomainSocketBaseFilePathA();
WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName);
+WINPR_API int GetNamePipeFileDescriptor(HANDLE hNamedPipe);
+
#ifdef __cplusplus
}
#endif
pNamedPipe->clientfd = socket(PF_LOCAL, SOCK_STREAM, 0);
pNamedPipe->serverfd = -1;
+ pNamedPipe->ServerMode = FALSE;
if (0)
{
return lpFilePath;
}
+int GetNamePipeFileDescriptor(HANDLE hNamedPipe)
+{
+#ifndef _WIN32
+ int fd;
+ WINPR_NAMED_PIPE* pNamedPipe;
+
+ pNamedPipe = (WINPR_NAMED_PIPE*) hNamedPipe;
+
+ if (!pNamedPipe)
+ return -1;
+
+ fd = (pNamedPipe->ServerMode) ? pNamedPipe->serverfd : pNamedPipe->clientfd;
+
+ return fd;
+#else
+ return -1;
+#endif
+}
+
int UnixChangeFileMode(const char* filename, int flags)
{
#ifndef _WIN32
lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA();
if (!PathFileExistsA(lpPipePath))
+ {
CreateDirectoryA(lpPipePath, 0);
+ UnixChangeFileMode(lpPipePath, 0xFFFF);
+ }
free(lpPipePath);
pNamedPipe->clientfd = -1;
pNamedPipe->serverfd = socket(PF_LOCAL, SOCK_STREAM, 0);
+ pNamedPipe->ServerMode = TRUE;
if (0)
{
}
else if (Type == HANDLE_TYPE_NAMED_PIPE)
{
+ int fd;
int status;
fd_set rfds;
struct timeval timeout;
WINPR_NAMED_PIPE* pipe = (WINPR_NAMED_PIPE*) Object;
+ fd = (pipe->ServerMode) ? pipe->serverfd : pipe->clientfd;
+
+ if (fd == -1)
+ return WAIT_FAILED;
+
FD_ZERO(&rfds);
- FD_SET(pipe->clientfd, &rfds);
+ FD_SET(fd, &rfds);
ZeroMemory(&timeout, sizeof(timeout));
if ((dwMilliseconds != INFINITE) && (dwMilliseconds != 0))
timeout.tv_usec = dwMilliseconds * 1000;
}
- status = select(pipe->clientfd + 1, &rfds, NULL, NULL,
+ status = select(fd + 1, &rfds, NULL, NULL,
(dwMilliseconds == INFINITE) ? NULL : &timeout);
if (status < 0)
else if (Type == HANDLE_TYPE_NAMED_PIPE)
{
WINPR_NAMED_PIPE* pipe = (WINPR_NAMED_PIPE*) Object;
- fd = pipe->clientfd;
+ fd = (pipe->ServerMode) ? pipe->serverfd : pipe->clientfd;
+
+ if (fd == -1)
+ return WAIT_FAILED;
}
else
{
else if (Type == HANDLE_TYPE_NAMED_PIPE)
{
WINPR_NAMED_PIPE* pipe = (WINPR_NAMED_PIPE*) Object;
- fd = pipe->clientfd;
+ fd = (pipe->ServerMode) ? pipe->serverfd : pipe->clientfd;
}
if (FD_ISSET(fd, &fds))