mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 01:25:56 +00:00
- fixed ConnectNamedPipe to properly wait on completion for synchronous operations
- prevent completion port notification by not passing an APC context to the kernel when the low-order bit of the event handle is set (for asynchronous operations) svn path=/trunk/; revision=15048
This commit is contained in:
parent
f16e5b9e1d
commit
ecba32de75
1 changed files with 60 additions and 44 deletions
|
@ -300,55 +300,71 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
ConnectNamedPipe(HANDLE hNamedPipe,
|
ConnectNamedPipe(IN HANDLE hNamedPipe,
|
||||||
LPOVERLAPPED lpOverlapped)
|
IN LPOVERLAPPED lpOverlapped)
|
||||||
{
|
{
|
||||||
PIO_STATUS_BLOCK IoStatusBlock;
|
NTSTATUS Status;
|
||||||
IO_STATUS_BLOCK Iosb;
|
|
||||||
HANDLE hEvent;
|
if (lpOverlapped != NULL)
|
||||||
NTSTATUS Status;
|
{
|
||||||
|
PVOID ApcContext;
|
||||||
|
|
||||||
|
lpOverlapped->Internal = STATUS_PENDING;
|
||||||
|
ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
|
||||||
|
|
||||||
|
Status = NtFsControlFile(hNamedPipe,
|
||||||
|
lpOverlapped->hEvent,
|
||||||
|
NULL,
|
||||||
|
ApcContext,
|
||||||
|
(PIO_STATUS_BLOCK)lpOverlapped,
|
||||||
|
FSCTL_PIPE_LISTEN,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
if (lpOverlapped != NULL)
|
/* return FALSE in case of failure and pending operations! */
|
||||||
{
|
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
|
||||||
lpOverlapped->Internal = STATUS_PENDING;
|
{
|
||||||
hEvent = lpOverlapped->hEvent;
|
SetLastErrorByStatus(Status);
|
||||||
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverlapped;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
IoStatusBlock = &Iosb;
|
{
|
||||||
hEvent = NULL;
|
IO_STATUS_BLOCK Iosb;
|
||||||
}
|
|
||||||
|
Status = NtFsControlFile(hNamedPipe,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&Iosb,
|
||||||
|
FSCTL_PIPE_LISTEN,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0);
|
||||||
|
|
||||||
Status = NtFsControlFile(hNamedPipe,
|
/* wait in case operation is pending */
|
||||||
hEvent,
|
if (Status == STATUS_PENDING)
|
||||||
NULL,
|
{
|
||||||
NULL,
|
Status = NtWaitForSingleObject(hNamedPipe,
|
||||||
IoStatusBlock,
|
FALSE,
|
||||||
FSCTL_PIPE_LISTEN,
|
NULL);
|
||||||
NULL,
|
if (NT_SUCCESS(Status))
|
||||||
0,
|
{
|
||||||
NULL,
|
Status = Iosb.Status;
|
||||||
0);
|
}
|
||||||
if ((lpOverlapped == NULL) && (Status == STATUS_PENDING))
|
}
|
||||||
{
|
|
||||||
Status = NtWaitForSingleObject(hNamedPipe,
|
|
||||||
FALSE,
|
|
||||||
NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
Status = Iosb.Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!NT_SUCCESS(Status) && Status != STATUS_PIPE_CONNECTED) ||
|
if (!NT_SUCCESS(Status))
|
||||||
(Status == STATUS_PENDING))
|
{
|
||||||
{
|
SetLastErrorByStatus(Status);
|
||||||
SetLastErrorByStatus(Status);
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue