1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Add new thread-testing code and fix locking under Linux threads. Ticket #530. (CVS 1137)

FossilOrigin-Name: b36a4bb61094d539273c21a9e4042384f10a7806
This commit is contained in:
drh
2003-12-19 02:52:05 +00:00
parent 9c4dcca89e
commit a6064dcf3b
7 changed files with 722 additions and 29 deletions

View File

@@ -61,6 +61,24 @@
# define fcntl(A,B,C) 0
#endif
/*
** Macros used to determine whether or not to use threads. The
** SQLITE_UNIX_THREADS macro is defined if we are synchronizing for
** Posix threads and SQLITE_W32_THREADS is defined if we are
** synchronizing using Win32 threads.
*/
#if OS_UNIX && defined(THREADSAFE) && THREADSAFE
# include <pthread.h>
# define SQLITE_UNIX_THREADS 1
#endif
#if OS_WIN && defined(THREADSAFE) && THREADSAFE
# define SQLITE_W32_THREADS 1
#endif
#if OS_MAC && defined(THREADSAFE) && THREADSAFE
# include <Multiprocessing.h>
# define SQLITE_MACOS_MULTITASKING 1
#endif
/*
** Macros for performance tracing. Normally turned off
*/
@@ -155,6 +173,9 @@ static unsigned int elapse;
struct inodeKey {
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
#ifdef SQLITE_UNIX_THREADS
pthread_t thread_id; /* Which thread are we */
#endif
};
/*
@@ -190,6 +211,9 @@ static struct lockInfo *findLockInfo(int fd){
memset(&key, 0, sizeof(key));
key.dev = statbuf.st_dev;
key.ino = statbuf.st_ino;
#ifdef SQLITE_UNIX_THREADS
key.thread_id = pthread_self();
#endif
pInfo = (struct lockInfo*)sqliteHashFind(&lockHash, &key, sizeof(key));
if( pInfo==0 ){
struct lockInfo *pOld;
@@ -1467,24 +1491,6 @@ int sqliteOsSleep(int ms){
#endif
}
/*
** Macros used to determine whether or not to use threads. The
** SQLITE_UNIX_THREADS macro is defined if we are synchronizing for
** Posix threads and SQLITE_W32_THREADS is defined if we are
** synchronizing using Win32 threads.
*/
#if OS_UNIX && defined(THREADSAFE) && THREADSAFE
# include <pthread.h>
# define SQLITE_UNIX_THREADS 1
#endif
#if OS_WIN && defined(THREADSAFE) && THREADSAFE
# define SQLITE_W32_THREADS 1
#endif
#if OS_MAC && defined(THREADSAFE) && THREADSAFE
# include <Multiprocessing.h>
# define SQLITE_MACOS_MULTITASKING 1
#endif
/*
** Static variables used for thread synchronization
*/