#include "pal/thread.hpp"
#include "pal/file.hpp"
-#include "shmfilelockmgr.hpp"
#include "pal/malloc.hpp"
#include "pal/stackstring.hpp"
);
CAllowedObjectTypes CorUnix::aotFile(otiFile);
-static CSharedMemoryFileLockMgr _FileLockManager;
-IFileLockManager *CorUnix::g_pFileLockManager = &_FileLockManager;
void
CFileProcessLocalDataCleanupRoutine(
return;
}
- if (pLocalData->pLockController != NULL)
- {
- pLocalData->pLockController->ReleaseController();
- }
-
if (!fShutdown && -1 != pLocalData->unix_fd)
{
close(pLocalData->unix_fd);
IPalObject *pRegisteredFile = NULL;
IDataLock *pDataLock = NULL;
CFileProcessLocalData *pLocalData = NULL;
- IFileLockController *pLockController = NULL;
CObjectAttributes oaFile(NULL, lpSecurityAttributes);
BOOL fFileExists = FALSE;
goto done;
}
- //
- // The file sharing mode checks are performed by the lock manager so we need
- // to get the lock controller for this file.
- // Do this before modifying the file system since we wouldn't want to, for
- // instance, truncate a file before finding out if we have write access to it.
- // It may seem odd that in some cases we will acquire a lock on a file that
- // doesn't exist yet but the lock manager does not care -- files are
- // abstract entities represented by a name from its point of view.
- //
-
- palError = g_pFileLockManager->GetLockControllerForFile(
- pThread,
- lpUnixPath,
- dwDesiredAccess,
- dwShareMode,
- &pLockController
- );
-
- if (NO_ERROR != palError)
- {
- goto done;
- }
-
/* NB: According to MSDN docs, When CREATE_ALWAYS or OPEN_ALWAYS is
set, CreateFile should SetLastError to ERROR_ALREADY_EXISTS,
even though/if CreateFile will be successful.
pLocalData->open_flags_deviceaccessonly = (dwDesiredAccess == 0);
//
- // Transfer the lock controller reference from our local variable
- // to the local file data
- //
-
- pLocalData->pLockController = pLockController;
- pLockController = NULL;
-
- //
// We've finished initializing our local data, so release that lock
//
}
}
- if (NULL != pLockController)
- {
- pLockController->ReleaseController();
- }
-
if (NULL != pDataLock)
{
pDataLock->ReleaseLock(pThread, TRUE);
IPalObject *pFileObject = NULL;
CFileProcessLocalData *pLocalData = NULL;
IDataLock *pLocalDataLock = NULL;
- IFileTransactionLock *pTransactionLock = NULL;
int ifd;
LONG writeOffsetStartLow = 0, writeOffsetStartHigh = 0;
ifd = pLocalData->unix_fd;
//
- // Inform the lock controller for this file (if any) of our intention
- // to perform a write. (Note that pipes don't have lock controllers.)
- //
-
- if (NULL != pLocalData->pLockController)
- {
- /* Get the current file position to calculate the region to lock */
- palError = InternalSetFilePointerForUnixFd(
- ifd,
- 0,
- &writeOffsetStartHigh,
- FILE_CURRENT,
- &writeOffsetStartLow
- );
-
- if (NO_ERROR != palError)
- {
- ASSERT("Failed to get the current file position\n");
- palError = ERROR_INTERNAL_ERROR;
- goto done;
- }
-
- palError = pLocalData->pLockController->GetTransactionLock(
- pThread,
- IFileLockController::WriteLock,
- writeOffsetStartLow,
- writeOffsetStartHigh,
- nNumberOfBytesToWrite,
- 0,
- &pTransactionLock
- );
-
- if (NO_ERROR != palError)
- {
- ERROR("Unable to obtain write transaction lock");
- goto done;
- }
- }
-
- //
// Release the data lock before performing the (possibly blocking)
// write call
//
done:
- if (NULL != pTransactionLock)
- {
- pTransactionLock->ReleaseLock();
- }
-
if (NULL != pLocalDataLock)
{
pLocalDataLock->ReleaseLock(pThread, FALSE);
IPalObject *pFileObject = NULL;
CFileProcessLocalData *pLocalData = NULL;
IDataLock *pLocalDataLock = NULL;
- IFileTransactionLock *pTransactionLock = NULL;
int ifd;
LONG readOffsetStartLow = 0, readOffsetStartHigh = 0;
ifd = pLocalData->unix_fd;
//
- // Inform the lock controller for this file (if any) of our intention
- // to perform a read. (Note that pipes don't have lock controllers.)
- //
-
- if (NULL != pLocalData->pLockController)
- {
- /* Get the current file position to calculate the region to lock */
- palError = InternalSetFilePointerForUnixFd(
- ifd,
- 0,
- &readOffsetStartHigh,
- FILE_CURRENT,
- &readOffsetStartLow
- );
-
- if (NO_ERROR != palError)
- {
- ASSERT("Failed to get the current file position\n");
- palError = ERROR_INTERNAL_ERROR;
- goto done;
- }
-
- palError = pLocalData->pLockController->GetTransactionLock(
- pThread,
- IFileLockController::ReadLock,
- readOffsetStartLow,
- readOffsetStartHigh,
- nNumberOfBytesToRead,
- 0,
- &pTransactionLock
- );
-
- if (NO_ERROR != palError)
- {
- ERROR("Unable to obtain read transaction lock");
- goto done;
- }
- }
-
- //
// Release the data lock before performing the (possibly blocking)
// read call
//
done:
- if (NULL != pTransactionLock)
- {
- pTransactionLock->ReleaseLock();
- }
-
if (NULL != pLocalDataLock)
{
pLocalDataLock->ReleaseLock(pThread, FALSE);
IPalObject *pRegisteredFile = NULL;
IDataLock *pDataLock = NULL;
CFileProcessLocalData *pLocalData = NULL;
- IFileLockController *pLockController = NULL;
CObjectAttributes oa;
HANDLE hFile = INVALID_HANDLE_VALUE;
pLocalData->open_flags_deviceaccessonly = FALSE;
//
- // Transfer the lock controller reference from our local variable
- // to the local file data
- //
-
- pLocalData->pLockController = pLockController;
- pLockController = NULL;
-
- //
// We've finished initializing our local data, so release that lock
//
done:
- if (NULL != pLockController)
- {
- pLockController->ReleaseController();
- }
-
if (NULL != pDataLock)
{
pDataLock->ReleaseLock(pThread, TRUE);