Delete dead code in PAL related to file locks (#16754)
[platform/upstream/coreclr.git] / src / pal / src / file / file.cpp
index b7bc780..3f453c1 100644 (file)
@@ -23,7 +23,6 @@ SET_DEFAULT_DEBUG_CHANNEL(FILE); // some headers have code with asserts, so do t
 
 #include "pal/thread.hpp"
 #include "pal/file.hpp"
-#include "shmfilelockmgr.hpp"
 #include "pal/malloc.hpp"
 #include "pal/stackstring.hpp"
 
@@ -91,8 +90,6 @@ CObjectType CorUnix::otFile(
                 );
 
 CAllowedObjectTypes CorUnix::aotFile(otiFile);
-static CSharedMemoryFileLockMgr _FileLockManager;
-IFileLockManager *CorUnix::g_pFileLockManager = &_FileLockManager;
 
 void
 CFileProcessLocalDataCleanupRoutine(
@@ -147,11 +144,6 @@ FileCleanupRoutine(
         return;
     }
 
-    if (pLocalData->pLockController != NULL)
-    {
-        pLocalData->pLockController->ReleaseController();
-    }
-
     if (!fShutdown && -1 != pLocalData->unix_fd)
     {
         close(pLocalData->unix_fd);
@@ -481,7 +473,6 @@ CorUnix::InternalCreateFile(
     IPalObject *pRegisteredFile = NULL;
     IDataLock *pDataLock = NULL;
     CFileProcessLocalData *pLocalData = NULL;
-    IFileLockController *pLockController = NULL;
     CObjectAttributes oaFile(NULL, lpSecurityAttributes);
     BOOL fFileExists = FALSE;
 
@@ -610,29 +601,6 @@ CorUnix::InternalCreateFile(
         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.
@@ -767,14 +735,6 @@ CorUnix::InternalCreateFile(
     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
     //
 
@@ -819,11 +779,6 @@ done:
         }
     }
 
-    if (NULL != pLockController)
-    {
-        pLockController->ReleaseController();
-    }
-
     if (NULL != pDataLock)
     {
         pDataLock->ReleaseLock(pThread, TRUE);
@@ -1848,7 +1803,6 @@ CorUnix::InternalWriteFile(
     IPalObject *pFileObject = NULL;
     CFileProcessLocalData *pLocalData = NULL;
     IDataLock *pLocalDataLock = NULL;
-    IFileTransactionLock *pTransactionLock = NULL;
     int ifd;
 
     LONG writeOffsetStartLow = 0, writeOffsetStartHigh = 0;
@@ -1918,46 +1872,6 @@ CorUnix::InternalWriteFile(
     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
     //
@@ -1989,11 +1903,6 @@ CorUnix::InternalWriteFile(
     
 done:
     
-    if (NULL != pTransactionLock)
-    {
-        pTransactionLock->ReleaseLock();
-    }
-
     if (NULL != pLocalDataLock)
     {
         pLocalDataLock->ReleaseLock(pThread, FALSE);
@@ -2069,7 +1978,6 @@ CorUnix::InternalReadFile(
     IPalObject *pFileObject = NULL;
     CFileProcessLocalData *pLocalData = NULL;
     IDataLock *pLocalDataLock = NULL;
-    IFileTransactionLock *pTransactionLock = NULL;
     int ifd;
     
     LONG readOffsetStartLow = 0, readOffsetStartHigh = 0;
@@ -2145,46 +2053,6 @@ CorUnix::InternalReadFile(
     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
     //
@@ -2214,11 +2082,6 @@ Read:
     
 done:
 
-    if (NULL != pTransactionLock)
-    {
-        pTransactionLock->ReleaseLock();
-    }
-
     if (NULL != pLocalDataLock)
     {
         pLocalDataLock->ReleaseLock(pThread, FALSE);
@@ -4135,7 +3998,6 @@ static HANDLE init_std_handle(HANDLE * pStd, FILE *stream)
     IPalObject *pRegisteredFile = NULL;
     IDataLock *pDataLock = NULL;
     CFileProcessLocalData *pLocalData = NULL;
-    IFileLockController *pLockController = NULL;
     CObjectAttributes oa;
 
     HANDLE hFile = INVALID_HANDLE_VALUE;
@@ -4181,14 +4043,6 @@ static HANDLE init_std_handle(HANDLE * pStd, FILE *stream)
     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
     //
 
@@ -4214,11 +4068,6 @@ static HANDLE init_std_handle(HANDLE * pStd, FILE *stream)
 
 done:
 
-    if (NULL != pLockController)
-    {
-        pLockController->ReleaseController();
-    }
-
     if (NULL != pDataLock)
     {
         pDataLock->ReleaseLock(pThread, TRUE);