do
{ /* free instance should be available first */
bPipeAvailable = WaitNamedPipeW(o3tl::toW(path->buffer), NMPWAIT_WAIT_FOREVER);
/* first try to open system pipe */ if (bPipeAvailable)
{
pPipe->m_File = CreateFileW(
o3tl::toW(path->buffer),
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
nullptr);
if (pPipe->m_File != INVALID_HANDLE_VALUE)
{ // We got it !
rtl_uString_release(name);
rtl_uString_release(path);
// We should try to transfer our privilege to become foreground process // to the other process, so that it may show popups (otherwise, they might // be blocked by SPI_GETFOREGROUNDLOCKTIMEOUT setting - // see SystemParametersInfo function at MSDN
ULONG ServerProcessId = 0; if (GetNamedPipeServerProcessId(pPipe->m_File, &ServerProcessId))
AllowSetForegroundWindow(ServerProcessId);
return pPipe;
} else
{ // Pipe instance maybe caught by another client -> try again
}
}
} while (bPipeAvailable);
}
/* if we reach here something went wrong */
osl_destroyPipeImpl(pPipe);
void SAL_CALL osl_releasePipe(oslPipe pPipe)
{ if (!pPipe) return;
if (osl_atomic_decrement(&(pPipe->m_Reference)) == 0)
{ if (!pPipe->m_bClosed)
osl_closePipe(pPipe);
osl_destroyPipeImpl(pPipe);
}
}
void SAL_CALL osl_closePipe(oslPipe pPipe)
{ if (pPipe && !pPipe->m_bClosed)
{
pPipe->m_bClosed = true; /* if we have a system pipe close it */ if (pPipe->m_File != INVALID_HANDLE_VALUE)
{
DisconnectNamedPipe(pPipe->m_File);
CloseHandle(pPipe->m_File);
}
}
}
if (!ConnectNamedPipe(pPipe->m_File, &os))
{ switch (GetLastError())
{ case ERROR_PIPE_CONNECTED: // Client already connected to pipe case ERROR_NO_DATA: // Client was connected but has already closed pipe end // should only appear in nonblocking mode but in fact does // in blocking asynchronous mode. break; case ERROR_PIPE_LISTENING: // Only for nonblocking mode but see ERROR_NO_DATA case ERROR_IO_PENDING: // This is normal if not client is connected yet case ERROR_MORE_DATA: // Should not happen // blocking call to accept if( !GetOverlappedResult(pPipe->m_File, &os, &nBytesTransferred, TRUE))
{ // Possible error could be that between ConnectNamedPipe and // GetOverlappedResult a connect took place.
switch (GetLastError())
{ case ERROR_PIPE_CONNECTED: // Pipe was already connected case ERROR_NO_DATA: // Pipe was connected but client has already closed -> ver fast client ;-) break; // Everything's fine !!! default: // Something went wrong return nullptr;
}
} break; default: // All other error say that somethings going wrong. return nullptr;
}
}
pAcceptedPipe = osl_createPipeImpl();
assert(pAcceptedPipe); // should never be the case that an oslPipe cannot be initialized
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.