aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2004-06-22 11:29:02 +0000
committerdanielk1977 <danielk1977@noemail.net>2004-06-22 11:29:02 +0000
commite3026636159753d40820aff2c21923f62fee9a1b (patch)
tree1b9c3c1d6983c8e3c80efa28d6f849e2c66a079e /src/os_unix.c
parent369340af3de293aedebf1227b5218a9e01b3826e (diff)
downloadsqlite-e3026636159753d40820aff2c21923f62fee9a1b.tar.gz
sqlite-e3026636159753d40820aff2c21923f62fee9a1b.zip
Add os_test.c. Not activated yet. (CVS 1655)
FossilOrigin-Name: d16b863849d1aa887fe403e25153b1e9df6b837e
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 8276c9e0b..e707835f1 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -513,44 +513,6 @@ int sqlite3OsTempFileName(char *zBuf){
}
/*
-** Close a file.
-*/
-int sqlite3OsClose(OsFile *id){
- if( !id->isOpen ) return SQLITE_OK;
- sqlite3OsUnlock(id, NO_LOCK);
- if( id->dirfd>=0 ) close(id->dirfd);
- id->dirfd = -1;
- sqlite3OsEnterMutex();
- if( id->pOpen->nLock ){
- /* If there are outstanding locks, do not actually close the file just
- ** yet because that would clear those locks. Instead, add the file
- ** descriptor to pOpen->aPending. It will be automatically closed when
- ** the last lock is cleared.
- */
- int *aNew;
- struct openCnt *pOpen = id->pOpen;
- pOpen->nPending++;
- aNew = sqliteRealloc( pOpen->aPending, pOpen->nPending*sizeof(int) );
- if( aNew==0 ){
- /* If a malloc fails, just leak the file descriptor */
- }else{
- pOpen->aPending = aNew;
- pOpen->aPending[pOpen->nPending-1] = id->h;
- }
- }else{
- /* There are no outstanding locks so we can close the file immediately */
- close(id->h);
- }
- releaseLockInfo(id->pLock);
- releaseOpenCnt(id->pOpen);
- sqlite3OsLeaveMutex();
- id->isOpen = 0;
- TRACE2("CLOSE %-3d\n", id->h);
- OpenCounter(-1);
- return SQLITE_OK;
-}
-
-/*
** Read data from a file into a buffer. Return SQLITE_OK if all
** bytes were read successfully and SQLITE_IOERR if anything goes
** wrong.
@@ -944,6 +906,44 @@ int sqlite3OsUnlock(OsFile *id, int locktype){
}
/*
+** Close a file.
+*/
+int sqlite3OsClose(OsFile *id){
+ if( !id->isOpen ) return SQLITE_OK;
+ sqlite3OsUnlock(id, NO_LOCK);
+ if( id->dirfd>=0 ) close(id->dirfd);
+ id->dirfd = -1;
+ sqlite3OsEnterMutex();
+ if( id->pOpen->nLock ){
+ /* If there are outstanding locks, do not actually close the file just
+ ** yet because that would clear those locks. Instead, add the file
+ ** descriptor to pOpen->aPending. It will be automatically closed when
+ ** the last lock is cleared.
+ */
+ int *aNew;
+ struct openCnt *pOpen = id->pOpen;
+ pOpen->nPending++;
+ aNew = sqliteRealloc( pOpen->aPending, pOpen->nPending*sizeof(int) );
+ if( aNew==0 ){
+ /* If a malloc fails, just leak the file descriptor */
+ }else{
+ pOpen->aPending = aNew;
+ pOpen->aPending[pOpen->nPending-1] = id->h;
+ }
+ }else{
+ /* There are no outstanding locks so we can close the file immediately */
+ close(id->h);
+ }
+ releaseLockInfo(id->pLock);
+ releaseOpenCnt(id->pOpen);
+ sqlite3OsLeaveMutex();
+ id->isOpen = 0;
+ TRACE2("CLOSE %-3d\n", id->h);
+ OpenCounter(-1);
+ return SQLITE_OK;
+}
+
+/*
** Get information to seed the random number generator. The seed
** is written into the buffer zBuf[256]. The calling function must
** supply a sufficiently large buffer.