namespace CorUnix
{
int InternalGlob(
- CPalThread *pthrCurrent,
const char *szPattern,
int nFlags,
#if ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS
Input parameters:
- pthrCurrent = reference to executing thread
szPattern = pointer to a pathname pattern to be expanded
nFlags = arguments to modify the behavior of glob
pnErrFunc = pointer to a routine that handles errors during the glob call
--*/
int
InternalGlob(
- CPalThread *pthrCurrent,
const char *szPattern,
int nFlags,
#if ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS
static int FILEGlobQsortCompare(const void *in_str1, const void *in_str2);
static int FILEGlobFromSplitPath(
- CPalThread *pthrCurrent,
const char *dir,
const char *fname,
const char *ext,
ie. calling splitpath on a pattern then calling this function should
produce the same result as just calling glob() on the pattern.
--*/
-static int FILEGlobFromSplitPath( CPalThread *pthrCurrent,
- const char *dir,
+static int FILEGlobFromSplitPath( const char *dir,
const char *fname,
const char *ext,
int flags,
#ifdef GLOB_QUOTE
flags |= GLOB_QUOTE;
#endif // GLOB_QUOTE
- Ret = InternalGlob(pthrCurrent, EscapedPattern, flags, NULL, pgGlob);
+ Ret = InternalGlob(EscapedPattern, flags, NULL, pgGlob);
#ifdef GLOB_NOMATCH
if (Ret == GLOB_NOMATCH)
if ( !(A && B) )
{
/* the original pattern */
- globResult = FILEGlobFromSplitPath(pthrCurrent, Dir, Filename, Ext, 0, pgGlob);
+ globResult = FILEGlobFromSplitPath(Dir, Filename, Ext, 0, pgGlob);
if ( globResult != 0 )
{
goto done;
if (C)
{
/* the original pattern but '.' prepended to filename */
- globResult = FILEGlobFromSplitPath(pthrCurrent, Dir, Filename - 1, Ext,
+ globResult = FILEGlobFromSplitPath(Dir, Filename - 1, Ext,
GLOB_APPEND, pgGlob);
if ( globResult != 0 )
{
/* if (A && B), this is the first glob() call. The first call
to glob must use flags = 0, while proceeding calls should
set the GLOB_APPEND flag. */
- globResult = FILEGlobFromSplitPath(pthrCurrent, Dir, Filename, "",
+ globResult = FILEGlobFromSplitPath(Dir, Filename, "",
(A && B)?0:GLOB_APPEND, pgGlob);
if ( globResult != 0 )
{
if (C)
{
/* omit the extension and prepend '.' to filename */
- globResult = FILEGlobFromSplitPath(pthrCurrent, Dir, Filename - 1, "",
+ globResult = FILEGlobFromSplitPath(Dir, Filename - 1, "",
GLOB_APPEND, pgGlob);
if ( globResult != 0 )
{
);
void
- FreeBuffer(
- CPalThread *pthr
- );
+ FreeBuffer();
const WCHAR *
GetString()
PAL_ERROR
InitializeProcessCommandLine(
- CPalThread *pThread,
LPWSTR lpwstrCmdLine,
LPWSTR lpwstrFullPath
);
}
#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
- PAL_ERROR RunDeferredThreadConditionSignalings(CPalThread * pthrCurrent);
+ PAL_ERROR RunDeferredThreadConditionSignalings();
#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
// NOTE: the following methods provide non-synchronized access to
class CPalSynchMgrController
{
public:
- static IPalSynchronizationManager * CreatePalSynchronizationManager(
- CPalThread * pthrCurrent);
+ static IPalSynchronizationManager * CreatePalSynchronizationManager();
static PAL_ERROR StartWorker(CPalThread * pthrCurrent);
// Initialize the synchronization manager
//
g_pSynchronizationManager =
- CPalSynchMgrController::CreatePalSynchronizationManager(pThread);
+ CPalSynchMgrController::CreatePalSynchronizationManager();
if (NULL == g_pSynchronizationManager)
{
}
palError = InitializeProcessCommandLine(
- pThread,
command_line,
exe_path);
static PAL_ERROR
MAPRecordMapping(
- CPalThread *pThread,
IPalObject *pMappingObject,
void *pPEBaseAddress,
void *addr,
static PAL_ERROR
MAPmmapAndRecord(
- CPalThread *pThread,
IPalObject *pMappingObject,
void *pPEBaseAddress,
void *addr,
// This call assumes the mapping_critsec has already been taken.
static PAL_ERROR
MAPRecordMapping(
- CPalThread *pThread,
IPalObject *pMappingObject,
void *pPEBaseAddress,
void *addr,
// This call assumes the mapping_critsec has already been taken.
static PAL_ERROR
MAPmmapAndRecord(
- CPalThread *pThread,
IPalObject *pMappingObject,
void *pPEBaseAddress,
void *addr,
}
else
{
- palError = MAPRecordMapping(pThread, pMappingObject, pPEBaseAddress, pvBaseAddress, len, prot);
+ palError = MAPRecordMapping(pMappingObject, pPEBaseAddress, pvBaseAddress, len, prot);
if (NO_ERROR != palError)
{
if (-1 == munmap(pvBaseAddress, len))
headerSize = VIRTUAL_PAGE_SIZE; // if there are lots of sections, this could be wrong
//first, map the PE header to the first page in the image. Get pointers to the section headers
- palError = MAPmmapAndRecord(pThread, pFileObject, loadedBase,
+ palError = MAPmmapAndRecord(pFileObject, loadedBase,
loadedBase, headerSize, PROT_READ, MAP_FILE|MAP_PRIVATE|MAP_FIXED, fd, 0,
(void**)&loadedHeader);
if (NO_ERROR != palError)
if ((char*)prevSectionBase + prevSectionSizeInMemory < sectionBase)
{
char* gapBase = (char*)prevSectionBase + prevSectionSizeInMemory;
- palError = MAPRecordMapping(pThread, pFileObject,
+ palError = MAPRecordMapping(pFileObject,
loadedBase,
(void*)gapBase,
(char*)sectionBase - gapBase,
if (currentHeader.Characteristics & IMAGE_SCN_MEM_WRITE)
prot |= PROT_WRITE;
- palError = MAPmmapAndRecord(pThread, pFileObject, loadedBase,
+ palError = MAPmmapAndRecord(pFileObject, loadedBase,
sectionBase,
currentHeader.SizeOfRawData,
prot,
if ((char*)prevSectionBase + prevSectionSizeInMemory < imageEnd)
{
char* gapBase = (char*)prevSectionBase + prevSectionSizeInMemory;
- palError = MAPRecordMapping(pThread, pFileObject,
+ palError = MAPRecordMapping(pFileObject,
loadedBase,
(void*)gapBase,
imageEnd - gapBase,
Frees the contained string buffer
-Parameters:
- pthr -- thread data for calling thread
--*/
void
-CPalString::FreeBuffer(
- CPalThread *pthr
- )
+CPalString::FreeBuffer()
{
_ASSERTE(NULL != m_pwsz);
-
InternalFree(const_cast<WCHAR*>(m_pwsz));
}
{
ENTRY("CPalObjectBase::~CPalObjectBase(this = %p)\n", this);
- // There is no need to call InternalGetCurrentThread here because
- // ReleaseReference already stores the thread object that
- // deletes this object in m_pthrCleanup to make sure the
- // thread object is alive throughout the object cleanup process.
-
if (NULL != m_pvImmutableData)
{
InternalFree(m_pvImmutableData);
if (NULL != m_oa.sObjectName.GetString())
{
- m_oa.sObjectName.FreeBuffer(m_pthrCleanup);
+ m_oa.sObjectName.FreeBuffer();
}
LOGEXIT("CPalObjectBase::~CPalObjectBase\n");
Creates the Synchronization Manager. It must be called once per process.
--*/
- IPalSynchronizationManager * CPalSynchMgrController::CreatePalSynchronizationManager(
- CPalThread *pthrCurrent)
+ IPalSynchronizationManager * CPalSynchMgrController::CreatePalSynchronizationManager()
{
- return CPalSynchronizationManager::CreatePalSynchronizationManager(pthrCurrent);
+ return CPalSynchronizationManager::CreatePalSynchronizationManager();
};
/*++
Creates the Synchronization Manager.
Private method, it is called only by CPalSynchMgrController.
--*/
- IPalSynchronizationManager * CPalSynchronizationManager::CreatePalSynchronizationManager(
- CPalThread *pthrCurrent)
+ IPalSynchronizationManager * CPalSynchronizationManager::CreatePalSynchronizationManager()
{
- IPalSynchronizationManager * pRet = NULL;
+ IPalSynchronizationManager * pRet = NULL;
if (s_pObjSynchMgr == NULL)
{
- Initialize(pthrCurrent);
+ Initialize();
pRet = static_cast<IPalSynchronizationManager *>(s_pObjSynchMgr);
}
else
Internal Synchronization Manager initialization
--*/
- PAL_ERROR CPalSynchronizationManager::Initialize(
- CPalThread *pthrCurrent)
- {
+ PAL_ERROR CPalSynchronizationManager::Initialize()
+ {
PAL_ERROR palErr = NO_ERROR;
LONG lInit;
CPalSynchronizationManager * pSynchManager = NULL;
goto I_exit;
}
- if (!pSynchManager->CreateProcessPipe(pthrCurrent))
+ if (!pSynchManager->CreateProcessPipe())
{
ERROR("Unable to create process pipe \n");
palErr = ERROR_OPEN_FAILED;
s_pObjSynchMgr = pSynchManager;
// Initialization was successful
- g_pSynchronizationManager =
- static_cast<IPalSynchronizationManager *>(pSynchManager);
+ g_pSynchronizationManager =
+ static_cast<IPalSynchronizationManager *>(pSynchManager);
s_lInitStatus = (LONG)SynchMgrStatusRunning;
I_exit:
s_lInitStatus = (LONG)SynchMgrStatusError;
if (NULL != pSynchManager)
{
- pSynchManager->ShutdownProcessPipe(pthrCurrent);
+ pSynchManager->ShutdownProcessPipe();
}
s_pObjSynchMgr = NULL;
g_pSynchronizationManager = NULL;
SynchMgrStatusRunning, lInit);
// We intentionally not set s_lInitStatus to SynchMgrStatusError
// cause this could interfere with a previous thread already
- // executing shutdown
+ // executing shutdown
palErr = ERROR_INTERNAL_ERROR;
goto PFS_exit;
}
// Discard process monitoring for process waits
- pSynchManager->DiscardMonitoredProcesses(pthrCurrent);
+ pSynchManager->DiscardMonitoredProcesses(pthrCurrent);
if (NULL == pSynchManager->m_pipoThread)
{
// sometime after having called CreatePalSynchronizationManager,
// but before calling StartWorker. Nothing else to do here.
goto PFS_exit;
- }
+ }
- palErr = pSynchManager->WakeUpLocalWorkerThread(pthrCurrent,
- SynchWorkerCmdShutdown);
+ palErr = pSynchManager->WakeUpLocalWorkerThread(SynchWorkerCmdShutdown);
if (NO_ERROR != palErr)
{
ERROR("Failed stopping worker thread [palErr=%u]\n", palErr);
ERROR("Failed to convert timeout to absolute timeout\n");
s_lInitStatus = SynchMgrStatusError;
goto PFS_exit;
- }
+ }
// Using the worker thread's predicate/condition/mutex
// to wait for worker thread to be done
// be read). That will allow the worker thread to process
// possible commands already successfully written to the
// pipe by some other process, before shutting down.
- pSynchManager->ShutdownProcessPipe(pthrWorker);
+ pSynchManager->ShutdownProcessPipe();
// Shutting down: this will cause the worker thread to
// fetch residual cmds from the process pipe until an
process pipe.
--*/
PAL_ERROR CPalSynchronizationManager::WakeUpLocalWorkerThread(
- CPalThread * pthrCurrent,
SynchWorkerCmd swcWorkerCmd)
{
PAL_ERROR palErr = NO_ERROR;
{
CPalSynchronizationManager * pSynchManager = GetInstance();
- palErr = pSynchManager->WakeUpLocalWorkerThread(pthrCurrent,
- SynchWorkerCmdNop);
+ palErr = pSynchManager->WakeUpLocalWorkerThread(SynchWorkerCmdNop);
if (NO_ERROR != palErr)
{
ERROR("Failed waking up worker thread for process "
Creates the process pipe for the current process
--*/
- bool CPalSynchronizationManager::CreateProcessPipe(
- CPalThread * pthrCurrent)
+ bool CPalSynchronizationManager::CreateProcessPipe()
{
bool fRet = true;
#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT
Shuts down the process pipe and removes the fifo so that other processes
can no longer open it. It also closes the local write end of the pipe (see
- comment below). From this moment on the worker thread will process any
+ comment below). From this moment on the worker thread will process any
possible data already received in the pipe (but not yet consumed) and any
- data written by processes that still have a opened write end of this pipe;
+ data written by processes that still have a opened write end of this pipe;
it will wait (with timeout) until the last remote process which has a write
- end opened closes it, and then it will yield to process shutdown
+ end opened closes it, and then it will yield to process shutdown.
--*/
- PAL_ERROR CPalSynchronizationManager::ShutdownProcessPipe(
- CPalThread *pthrCurrent)
+ PAL_ERROR CPalSynchronizationManager::ShutdownProcessPipe()
{
PAL_ERROR palErr = NO_ERROR;
#ifndef CORECLR
Carries out all the pending condition signalings for the current thread.
--*/
- PAL_ERROR CThreadSynchronizationInfo::RunDeferredThreadConditionSignalings(
- CPalThread * pthrCurrent)
+ PAL_ERROR CThreadSynchronizationInfo::RunDeferredThreadConditionSignalings()
{
PAL_ERROR palErr = NO_ERROR;
COwnedObjectsListNodeCache m_cacheOwnedObjectsListNodes;
// static methods
- static PAL_ERROR Initialize(CPalThread * pthrCurrent);
+ static PAL_ERROR Initialize();
static DWORD PALAPI WorkerThread(LPVOID pArg);
protected:
CSynchControllerBase::ControllerType ctCtrlrType);
private:
- static IPalSynchronizationManager * CreatePalSynchronizationManager(
- CPalThread * pthrCurrent);
+ static IPalSynchronizationManager * CreatePalSynchronizationManager();
static PAL_ERROR StartWorker(CPalThread * pthrCurrent);
static PAL_ERROR PrepareForShutdown(void);
InternalLeaveCriticalSection(pthrCurrent, &s_csSynchProcessLock);
#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
- pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings(pthrCurrent);
+ pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings();
#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
}
}
InternalLeaveCriticalSection(pthrCurrent, &s_csSynchProcessLock);
#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
- pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings(pthrCurrent);
+ pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings();
#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING && !SYNCHMGR_PIPE_BASED_THREAD_BLOCKING
}
return lRet;
}
static LONG GetLocalSynchLockCount(CPalThread * pthrCurrent)
{
- _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount);
+ _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount);
return pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount;
}
DWORD * pdwData);
PAL_ERROR WakeUpLocalWorkerThread(
- CPalThread * pthrCurrent,
SynchWorkerCmd swcWorkerCmd);
void DiscardAllPendingAPCs(
BYTE * pRecvBuf,
LONG lBytes);
- bool CreateProcessPipe(CPalThread * pthrCurrent);
+ bool CreateProcessPipe();
- PAL_ERROR ShutdownProcessPipe(CPalThread * pthrCurrent);
+ PAL_ERROR ShutdownProcessPipe();
public:
//
Initializes (or re-initializes) the saved command line and exe path.
Parameter
- pThread - the initial thread
lpwstrCmdLine
lpwstrFullPath
PAL_ERROR
CorUnix::InitializeProcessCommandLine(
- CPalThread *pThread,
LPWSTR lpwstrCmdLine,
LPWSTR lpwstrFullPath
)
Return:
The fresh thread structure, NULL otherwise
--*/
-CPalThread* AllocTHREAD(CPalThread *pthr)
+CPalThread* AllocTHREAD()
{
CPalThread* pThread = NULL;
// Create the CPalThread for the thread
//
- pNewThread = AllocTHREAD(pThread);
+ pNewThread = AllocTHREAD();
if (NULL == pNewThread)
{
palError = ERROR_OUTOFMEMORY;
CPalThread *pThread = NULL;
/* Create the thread object */
- /* Passing NULL to AllocTHREAD since there is no thread reference to pass in. */
- pThread = AllocTHREAD(NULL);
+ pThread = AllocTHREAD();
if (NULL == pThread)
{
CObjectAttributes oa(NULL, lpThreadAttributes);
bool fThreadDataStoredInObject = FALSE;
- pDummyThread = AllocTHREAD(pThread);
+ pDummyThread = AllocTHREAD();
if (NULL == pDummyThread)
{
palError = ERROR_OUTOFMEMORY;