SQLite

Check-in [a582b15959]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the xInMutex method to the os-layer switch for testing whether or not mutexes are used correctly. (CVS 2851)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a582b159595ff8d31c81e9b3044711d6590d3f0e
User & Date: drh 2006-01-02 20:00:13.000
Context
2006-01-03
00:33
The sqlite TCL command no longer returns the hex address of the sqlite3* structure. Instead there is a new command in testfixture to find that information. (CVS 2852) (check-in: 70b228575e user: drh tags: trunk)
2006-01-02
20:00
Add the xInMutex method to the os-layer switch for testing whether or not mutexes are used correctly. (CVS 2851) (check-in: a582b15959 user: drh tags: trunk)
18:24
Additional tests for descending indices. Comment changes. (CVS 2850) (check-in: 2622c5242b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os.h.
213
214
215
216
217
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  int (*xDelete)(const char*);
  int (*xFileExists)(const char*);
  char *(*xFullPathname)(const char*);
  int (*xIsDirWritable)(char*);
  int (*xSyncDirectory)(const char*);
  int (*xTempFileName)(char*);

  int  (*xRandomSeed)(char*);
  int  (*xSleep)(int ms);
  int  (*xCurrentTime)(double*);

  void (*xEnterMutex)(void);
  void (*xLeaveMutex)(void);

  void *(*xThreadSpecificData)(int);

  void *(*xMalloc)(int);
  void *(*xRealloc)(void *, int);
  void (*xFree)(void *);
  int (*xAllocationSize)(void *);
} sqlite3Os;


/*
** The semi-published API for setting and getting methods from the 
** global sqlite3OsVtbl structure. Neither sqlite3_os_routine_XXX() function
** is intriniscally thread-safe.
**
** External get/set access is only provided to the routines identified 
** by the hash-defined SQLITE_OS_ROUTINE symbols.
*/
#define SQLITE_OS_ROUTINE_OPENREADWRITE   1
#define SQLITE_OS_ROUTINE_OPENREADONLY    2
#define SQLITE_OS_ROUTINE_OPENEXCLUSIVE   3
#define SQLITE_OS_ROUTINE_DELETE          4
#define SQLITE_OS_ROUTINE_FILEEXISTS      5
#define SQLITE_OS_ROUTINE_SYNCDIRECTORY   6







|
|
|



>















|







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  int (*xDelete)(const char*);
  int (*xFileExists)(const char*);
  char *(*xFullPathname)(const char*);
  int (*xIsDirWritable)(char*);
  int (*xSyncDirectory)(const char*);
  int (*xTempFileName)(char*);

  int (*xRandomSeed)(char*);
  int (*xSleep)(int ms);
  int (*xCurrentTime)(double*);

  void (*xEnterMutex)(void);
  void (*xLeaveMutex)(void);
  int (*xInMutex)(void);
  void *(*xThreadSpecificData)(int);

  void *(*xMalloc)(int);
  void *(*xRealloc)(void *, int);
  void (*xFree)(void *);
  int (*xAllocationSize)(void *);
} sqlite3Os;


/*
** The semi-published API for setting and getting methods from the 
** global sqlite3OsVtbl structure. Neither sqlite3_os_routine_XXX() function
** is intriniscally thread-safe.
**
** External get/set access is only provided to the routines identified 
** by the following SQLITE_OS_ROUTINE symbols:
*/
#define SQLITE_OS_ROUTINE_OPENREADWRITE   1
#define SQLITE_OS_ROUTINE_OPENREADONLY    2
#define SQLITE_OS_ROUTINE_OPENEXCLUSIVE   3
#define SQLITE_OS_ROUTINE_DELETE          4
#define SQLITE_OS_ROUTINE_FILEEXISTS      5
#define SQLITE_OS_ROUTINE_SYNCDIRECTORY   6
Changes to src/os_unix.c.
1581
1582
1583
1584
1585
1586
1587










1588
1589
1590
1591
1592
1593
1594
static void unixLeaveMutex(){
  assert( inMutex );
  inMutex = 0;
#ifdef SQLITE_UNIX_THREADS
  pthread_mutex_unlock(&mutex);
#endif
}











/*
** This function is called automatically when a thread exists to delete
** the threads SqliteTsd structure. 
**
** Because the SqliteTsd structure is required by higher level routines
** such as sqliteMalloc() we use OsFree() and OsMalloc() directly to







>
>
>
>
>
>
>
>
>
>







1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
static void unixLeaveMutex(){
  assert( inMutex );
  inMutex = 0;
#ifdef SQLITE_UNIX_THREADS
  pthread_mutex_unlock(&mutex);
#endif
}

/*
** Return TRUE if we are currently within the mutex and FALSE if not.
** This routine is intended for sanity checking only.  It is designed
** for use in an assert() to verify that the mutex is held or not held
** in certain routines.
*/
static int unixInMutex(){
  return inMutex;
}

/*
** This function is called automatically when a thread exists to delete
** the threads SqliteTsd structure. 
**
** Because the SqliteTsd structure is required by higher level routines
** such as sqliteMalloc() we use OsFree() and OsMalloc() directly to
1702
1703
1704
1705
1706
1707
1708

1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
  IF_DISKIO( unixSyncDirectory ),
  IF_DISKIO( unixTempFileName ),
  unixRandomSeed,
  unixSleep,
  unixCurrentTime,
  unixEnterMutex,
  unixLeaveMutex,

  unixThreadSpecificData,
  genericMalloc,
  genericRealloc,
  genericFree,
  genericAllocationSize
};



#endif /* OS_UNIX */







>










1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
  IF_DISKIO( unixSyncDirectory ),
  IF_DISKIO( unixTempFileName ),
  unixRandomSeed,
  unixSleep,
  unixCurrentTime,
  unixEnterMutex,
  unixLeaveMutex,
  unixInMutex,
  unixThreadSpecificData,
  genericMalloc,
  genericRealloc,
  genericFree,
  genericAllocationSize
};



#endif /* OS_UNIX */
Changes to src/os_win.c.
985
986
987
988
989
990
991











992
993
994
995
996
997
998
static void winLeaveMutex(){
  assert( inMutex );
  inMutex = 0;
#ifdef SQLITE_W32_THREADS
  LeaveCriticalSection(&cs);
#endif
}












/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime().  This is used for testing.
*/
#ifdef SQLITE_TEST
int sqlite3_current_time = 0;







>
>
>
>
>
>
>
>
>
>
>







985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
static void winLeaveMutex(){
  assert( inMutex );
  inMutex = 0;
#ifdef SQLITE_W32_THREADS
  LeaveCriticalSection(&cs);
#endif
}

/*
** Return TRUE if we are currently within the mutex and FALSE if not.
** This routine is intended for sanity checking only.  It is designed
** for use in an assert() to verify that the mutex is held or not held
** in certain routines.
*/
static int winInMutex(){
  return inMutex;
}


/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime().  This is used for testing.
*/
#ifdef SQLITE_TEST
int sqlite3_current_time = 0;
1058
1059
1060
1061
1062
1063
1064

1065
1066
1067
1068
1069
1070
1071
1072
  IF_DISKIO( winSyncDirectory ),
  IF_DISKIO( winTempFileName ),
  winRandomSeed,
  winSleep,
  winCurrentTime,
  winEnterMutex,
  winLeaveMutex,

  winThreadSpecificData,
  genericMalloc,
  genericRealloc,
  genericFree,
  genericAllocationSize
};

#endif /* OS_WIN */







>








1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
  IF_DISKIO( winSyncDirectory ),
  IF_DISKIO( winTempFileName ),
  winRandomSeed,
  winSleep,
  winCurrentTime,
  winEnterMutex,
  winLeaveMutex,
  winInMutex,
  winThreadSpecificData,
  genericMalloc,
  genericRealloc,
  genericFree,
  genericAllocationSize
};

#endif /* OS_WIN */