Check for ERROR_PIPE_CONNECTED.

svn path=/trunk/; revision=27024
This commit is contained in:
Dmitry Gorbachev 2007-06-06 11:44:20 +00:00
parent cf7825f156
commit 822527aaa7
2 changed files with 15 additions and 5 deletions

View file

@ -34,9 +34,19 @@ DWORD WINAPI PipeThreadProc( LPVOID Parameter ) {
DWORD BytesRead, BytesWritten;
COMM_DHCP_REQ Req;
COMM_DHCP_REPLY Reply;
BOOL Result, Connection;
BOOL Result, Connected;
while( TRUE ) {
Connected = ConnectNamedPipe( CommPipe, NULL ) ?
TRUE : GetLastError() == ERROR_PIPE_CONNECTED;
if (!Connected) {
DbgPrint("DHCP: Could not connect named pipe\n");
CloseHandle( CommPipe );
CommPipe = INVALID_HANDLE_VALUE;
break;
}
while( (Connection = ConnectNamedPipe( CommPipe, NULL )) ) {
Result = ReadFile( CommPipe, &Req, sizeof(Req), &BytesRead, NULL );
if( Result ) {
switch( Req.Type ) {

View file

@ -744,7 +744,8 @@ ScmStartUserModeService(PSERVICE Service,
ResumeThread(ProcessInformation.hThread);
/* Connect control pipe */
if (ConnectNamedPipe(Service->ControlPipeHandle, NULL))
if (ConnectNamedPipe(Service->ControlPipeHandle, NULL) ?
TRUE : (dwError = GetLastError()) == ERROR_PIPE_CONNECTED)
{
DWORD dwProcessId = 0;
DWORD dwRead = 0;
@ -772,8 +773,7 @@ ScmStartUserModeService(PSERVICE Service,
}
else
{
dwError = GetLastError();
DPRINT("Connecting control pipe failed!\n");
DPRINT1("Connecting control pipe failed! (Error %lu)\n", dwError);
/* Close control pipe */
CloseHandle(Service->ControlPipeHandle);