Move the definition of function transferOwnership() in os_unix.c to below the static functions it calls. (CVS 5954)
FossilOrigin-Name: 622cb59791ab9f61c2e5131cb6ece5e75cdc9fae
This commit is contained in:
parent
46fdc8f586
commit
c015e39ff9
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Added\scast\sto\sPAGE_TO_PGHDR1\smacro\sto\sremove\swarning.\s\sIt\slooks\slike\sdespite\sthe\swarning,\sthe\scompiler\s(tested\swith\sVS2005\sand\sGCC\son\sWindows)\swas\sdoing\sthe\sright\sthing.\s\sTicket\s#3510.\s(CVS\s5953)
|
||||
D 2008-11-24T20:05:39
|
||||
C Move\sthe\sdefinition\sof\sfunction\stransferOwnership()\sin\sos_unix.c\sto\sbelow\sthe\sstatic\sfunctions\sit\scalls.\s(CVS\s5954)
|
||||
D 2008-11-25T12:07:41
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 0aa7bbe3be6acc4045706e3bb3fd0b8f38f4a3b5
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -137,7 +137,7 @@ F src/os.c 0b411644b87ad689d7250bbfd1834d99b81a3df4
|
||||
F src/os.h ef8abeb9afc694b82dbd169a91c9b7e26db3c892
|
||||
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
||||
F src/os_os2.c cd44723f5a7db824ff24823cddd4269310dc0d29
|
||||
F src/os_unix.c d6218ae6a616f4ac83b5f8bdeef2959a613bb016
|
||||
F src/os_unix.c add9937ac646b0f5f8dd603053ceb9264d675a60
|
||||
F src/os_win.c 3dff41670fb9798a869c636626bb7d6d8b6a45bb
|
||||
F src/pager.c e5d12e7adbab0dfcf11412f0492f4dfff9e1dc41
|
||||
F src/pager.h a02ef8e6cc7e78b54874166e5ce786c9d4c489bf
|
||||
@ -662,7 +662,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 7e134a5c1a9f103abd9d655483ad54cffae7e3ef
|
||||
R e05b777dd1cc800a136d32d50fffdbd5
|
||||
U shane
|
||||
Z a902d82e544694dcd73d59511a9b23de
|
||||
P e93cec0a72c7c330e63d38d683f4c8b63e0f8070
|
||||
R 8f1844c9450b2e989555a6b43e437908
|
||||
U danielk1977
|
||||
Z 33a17fcb7b184ca5395fc92f31848d89
|
||||
|
@ -1 +1 @@
|
||||
e93cec0a72c7c330e63d38d683f4c8b63e0f8070
|
||||
622cb59791ab9f61c2e5131cb6ece5e75cdc9fae
|
105
src/os_unix.c
105
src/os_unix.c
@ -12,7 +12,7 @@
|
||||
**
|
||||
** This file contains code that is specific to Unix systems.
|
||||
**
|
||||
** $Id: os_unix.c,v 1.220 2008/11/21 22:21:50 drh Exp $
|
||||
** $Id: os_unix.c,v 1.221 2008/11/25 12:07:41 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
||||
@ -512,57 +512,6 @@ static void testThreadLockingBehavior(int fd_orig){
|
||||
}
|
||||
#endif /* SQLITE_THERADSAFE && defined(__linux__) */
|
||||
|
||||
/*
|
||||
** If we are currently in a different thread than the thread that the
|
||||
** unixFile argument belongs to, then transfer ownership of the unixFile
|
||||
** over to the current thread.
|
||||
**
|
||||
** A unixFile is only owned by a thread on systems where one thread is
|
||||
** unable to override locks created by a different thread. RedHat9 is
|
||||
** an example of such a system.
|
||||
**
|
||||
** Ownership transfer is only allowed if the unixFile is currently unlocked.
|
||||
** If the unixFile is locked and an ownership is wrong, then return
|
||||
** SQLITE_MISUSE. SQLITE_OK is returned if everything works.
|
||||
*/
|
||||
#if SQLITE_THREADSAFE
|
||||
static int transferOwnership(unixFile *pFile){
|
||||
int rc;
|
||||
pthread_t hSelf;
|
||||
if( threadsOverrideEachOthersLocks ){
|
||||
/* Ownership transfers not needed on this system */
|
||||
return SQLITE_OK;
|
||||
}
|
||||
hSelf = pthread_self();
|
||||
if( pthread_equal(pFile->tid, hSelf) ){
|
||||
/* We are still in the same thread */
|
||||
OSTRACE1("No-transfer, same thread\n");
|
||||
return SQLITE_OK;
|
||||
}
|
||||
if( pFile->locktype!=NO_LOCK ){
|
||||
/* We cannot change ownership while we are holding a lock! */
|
||||
return SQLITE_MISUSE;
|
||||
}
|
||||
OSTRACE4("Transfer ownership of %d from %d to %d\n",
|
||||
pFile->h, pFile->tid, hSelf);
|
||||
pFile->tid = hSelf;
|
||||
if (pFile->pLock != NULL) {
|
||||
releaseLockInfo(pFile->pLock);
|
||||
rc = findLockInfo(pFile, &pFile->pLock, 0);
|
||||
OSTRACE5("LOCK %d is now %s(%s,%d)\n", pFile->h,
|
||||
locktypeName(pFile->locktype),
|
||||
locktypeName(pFile->pLock->locktype), pFile->pLock->cnt);
|
||||
return rc;
|
||||
} else {
|
||||
return SQLITE_OK;
|
||||
}
|
||||
}
|
||||
#else /* if not SQLITE_THREADSAFE */
|
||||
/* On single-threaded builds, ownership transfer is a no-op */
|
||||
# define transferOwnership(X) SQLITE_OK
|
||||
#endif /* SQLITE_THREADSAFE */
|
||||
|
||||
|
||||
/*
|
||||
** Release a unixLockInfo structure previously allocated by findLockInfo().
|
||||
*/
|
||||
@ -586,6 +535,7 @@ static void releaseLockInfo(struct unixLockInfo *pLock){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Release a unixOpenCnt structure previously allocated by findLockInfo().
|
||||
*/
|
||||
@ -1132,6 +1082,57 @@ static const char *locktypeName(int locktype){
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** If we are currently in a different thread than the thread that the
|
||||
** unixFile argument belongs to, then transfer ownership of the unixFile
|
||||
** over to the current thread.
|
||||
**
|
||||
** A unixFile is only owned by a thread on systems where one thread is
|
||||
** unable to override locks created by a different thread. RedHat9 is
|
||||
** an example of such a system.
|
||||
**
|
||||
** Ownership transfer is only allowed if the unixFile is currently unlocked.
|
||||
** If the unixFile is locked and an ownership is wrong, then return
|
||||
** SQLITE_MISUSE. SQLITE_OK is returned if everything works.
|
||||
*/
|
||||
#if SQLITE_THREADSAFE
|
||||
static int transferOwnership(unixFile *pFile){
|
||||
int rc;
|
||||
pthread_t hSelf;
|
||||
if( threadsOverrideEachOthersLocks ){
|
||||
/* Ownership transfers not needed on this system */
|
||||
return SQLITE_OK;
|
||||
}
|
||||
hSelf = pthread_self();
|
||||
if( pthread_equal(pFile->tid, hSelf) ){
|
||||
/* We are still in the same thread */
|
||||
OSTRACE1("No-transfer, same thread\n");
|
||||
return SQLITE_OK;
|
||||
}
|
||||
if( pFile->locktype!=NO_LOCK ){
|
||||
/* We cannot change ownership while we are holding a lock! */
|
||||
return SQLITE_MISUSE;
|
||||
}
|
||||
OSTRACE4("Transfer ownership of %d from %d to %d\n",
|
||||
pFile->h, pFile->tid, hSelf);
|
||||
pFile->tid = hSelf;
|
||||
if (pFile->pLock != NULL) {
|
||||
releaseLockInfo(pFile->pLock);
|
||||
rc = findLockInfo(pFile, &pFile->pLock, 0);
|
||||
OSTRACE5("LOCK %d is now %s(%s,%d)\n", pFile->h,
|
||||
locktypeName(pFile->locktype),
|
||||
locktypeName(pFile->pLock->locktype), pFile->pLock->cnt);
|
||||
return rc;
|
||||
} else {
|
||||
return SQLITE_OK;
|
||||
}
|
||||
}
|
||||
#else /* if not SQLITE_THREADSAFE */
|
||||
/* On single-threaded builds, ownership transfer is a no-op */
|
||||
# define transferOwnership(X) SQLITE_OK
|
||||
#endif /* SQLITE_THREADSAFE */
|
||||
|
||||
|
||||
/*
|
||||
** Seek to the offset passed as the second argument, then read cnt
|
||||
** bytes into pBuf. Return the number of bytes actually read.
|
||||
|
Loading…
Reference in New Issue
Block a user