/ Check-in [13686035]
Login

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

Overview
Comment:Add two new static mutexes, SQLITE_MUTEX_STATIC_APP1 and _APP2, for use by the application program. First intended use is in test programs for the memory allocation logic where one does not want to allocating a _FAST or _RECURSIVE mutex since that would involve using the memory allocation system under test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | threads
Files: files | file ages | folders
SHA1: 13686035dd1cf67ad9c6d282ab13c3259e7273d1
User & Date: drh 2014-05-03 12:00:01
Context
2014-05-03
13:53
Get SQLITE_MUTEX_STATIC_APP1 and _APP2 working for the debugMutex implementation. check-in: f49ba1c9 user: drh tags: threads
12:00
Add two new static mutexes, SQLITE_MUTEX_STATIC_APP1 and _APP2, for use by the application program. First intended use is in test programs for the memory allocation logic where one does not want to allocating a _FAST or _RECURSIVE mutex since that would involve using the memory allocation system under test. check-in: 13686035 user: drh tags: threads
11:22
Add the SQLITE_DEFAULT_WORKER_THREADS compile-time option. Fix a NULL-pointer dereference that can occur following OOM. check-in: e0dea89b user: drh tags: threads
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/mutex_unix.c.

    92     92   ** to sqlite3_mutex_alloc() is one of these integer constants:
    93     93   **
    94     94   ** <ul>
    95     95   ** <li>  SQLITE_MUTEX_FAST
    96     96   ** <li>  SQLITE_MUTEX_RECURSIVE
    97     97   ** <li>  SQLITE_MUTEX_STATIC_MASTER
    98     98   ** <li>  SQLITE_MUTEX_STATIC_MEM
    99         -** <li>  SQLITE_MUTEX_STATIC_MEM2
           99  +** <li>  SQLITE_MUTEX_STATIC_OPEN
   100    100   ** <li>  SQLITE_MUTEX_STATIC_PRNG
   101    101   ** <li>  SQLITE_MUTEX_STATIC_LRU
   102    102   ** <li>  SQLITE_MUTEX_STATIC_PMEM
          103  +** <li>  SQLITE_MUTEX_STATIC_APP1
          104  +** <li>  SQLITE_MUTEX_STATIC_APP2
   103    105   ** </ul>
   104    106   **
   105    107   ** The first two constants cause sqlite3_mutex_alloc() to create
   106    108   ** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
   107    109   ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
   108    110   ** The mutex implementation does not need to make a distinction
   109    111   ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
................................................................................
   124    126   ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
   125    127   ** returns a different mutex on every call.  But for the static 
   126    128   ** mutex types, the same mutex is returned on every call that has
   127    129   ** the same type number.
   128    130   */
   129    131   static sqlite3_mutex *pthreadMutexAlloc(int iType){
   130    132     static sqlite3_mutex staticMutexes[] = {
          133  +    SQLITE3_MUTEX_INITIALIZER,
          134  +    SQLITE3_MUTEX_INITIALIZER,
   131    135       SQLITE3_MUTEX_INITIALIZER,
   132    136       SQLITE3_MUTEX_INITIALIZER,
   133    137       SQLITE3_MUTEX_INITIALIZER,
   134    138       SQLITE3_MUTEX_INITIALIZER,
   135    139       SQLITE3_MUTEX_INITIALIZER,
   136    140       SQLITE3_MUTEX_INITIALIZER
   137    141     };

Changes to src/mutex_w32.c.

    95     95   */
    96     96   static sqlite3_mutex winMutex_staticMutexes[6] = {
    97     97     SQLITE3_MUTEX_INITIALIZER,
    98     98     SQLITE3_MUTEX_INITIALIZER,
    99     99     SQLITE3_MUTEX_INITIALIZER,
   100    100     SQLITE3_MUTEX_INITIALIZER,
   101    101     SQLITE3_MUTEX_INITIALIZER,
          102  +  SQLITE3_MUTEX_INITIALIZER,
          103  +  SQLITE3_MUTEX_INITIALIZER,
   102    104     SQLITE3_MUTEX_INITIALIZER
   103    105   };
   104    106   static int winMutex_isInit = 0;
   105    107   /* As winMutexInit() and winMutexEnd() are called as part
   106    108   ** of the sqlite3_initialize and sqlite3_shutdown()
   107    109   ** processing, the "interlocked" magic is probably not
   108    110   ** strictly necessary.
................................................................................
   155    157   ** to sqlite3_mutex_alloc() is one of these integer constants:
   156    158   **
   157    159   ** <ul>
   158    160   ** <li>  SQLITE_MUTEX_FAST
   159    161   ** <li>  SQLITE_MUTEX_RECURSIVE
   160    162   ** <li>  SQLITE_MUTEX_STATIC_MASTER
   161    163   ** <li>  SQLITE_MUTEX_STATIC_MEM
   162         -** <li>  SQLITE_MUTEX_STATIC_MEM2
          164  +** <li>  SQLITE_MUTEX_STATIC_OPEN
   163    165   ** <li>  SQLITE_MUTEX_STATIC_PRNG
   164    166   ** <li>  SQLITE_MUTEX_STATIC_LRU
   165    167   ** <li>  SQLITE_MUTEX_STATIC_PMEM
          168  +** <li>  SQLITE_MUTEX_STATIC_APP1
          169  +** <li>  SQLITE_MUTEX_STATIC_APP2
   166    170   ** </ul>
   167    171   **
   168    172   ** The first two constants cause sqlite3_mutex_alloc() to create
   169    173   ** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
   170    174   ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
   171    175   ** The mutex implementation does not need to make a distinction
   172    176   ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does

Changes to src/sqlite.h.in.

  5824   5824   ** to sqlite3_mutex_alloc() is one of these integer constants:
  5825   5825   **
  5826   5826   ** <ul>
  5827   5827   ** <li>  SQLITE_MUTEX_FAST
  5828   5828   ** <li>  SQLITE_MUTEX_RECURSIVE
  5829   5829   ** <li>  SQLITE_MUTEX_STATIC_MASTER
  5830   5830   ** <li>  SQLITE_MUTEX_STATIC_MEM
  5831         -** <li>  SQLITE_MUTEX_STATIC_MEM2
         5831  +** <li>  SQLITE_MUTEX_STATIC_OPEN
  5832   5832   ** <li>  SQLITE_MUTEX_STATIC_PRNG
  5833   5833   ** <li>  SQLITE_MUTEX_STATIC_LRU
  5834         -** <li>  SQLITE_MUTEX_STATIC_LRU2
         5834  +** <li>  SQLITE_MUTEX_STATIC_PMEM
         5835  +** <li>  SQLITE_MUTEX_STATIC_APP1
         5836  +** <li>  SQLITE_MUTEX_STATIC_APP2
  5835   5837   ** </ul>)^
  5836   5838   **
  5837   5839   ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
  5838   5840   ** cause sqlite3_mutex_alloc() to create
  5839   5841   ** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
  5840   5842   ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
  5841   5843   ** The mutex implementation does not need to make a distinction
................................................................................
  6031   6033   #define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */
  6032   6034   #define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */
  6033   6035   #define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */
  6034   6036   #define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_random() */
  6035   6037   #define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */
  6036   6038   #define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */
  6037   6039   #define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */
         6040  +#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */
         6041  +#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */
  6038   6042   
  6039   6043   /*
  6040   6044   ** CAPI3REF: Retrieve the mutex for a database connection
  6041   6045   **
  6042   6046   ** ^This interface returns a pointer the [sqlite3_mutex] object that 
  6043   6047   ** serializes access to the [database connection] given in the argument
  6044   6048   ** when the [threading mode] is Serialized.