/ Check-in [5764dc16]
Login

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

Overview
Comment:Allocation the mutex used by the unix VFS only once at initialization, instead of every time it is needed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5764dc160783f5c4017204b3e26a89d31240c868484ced8214c9ad872bd77bd4
User & Date: drh 2018-02-05 16:39:12
Context
2018-02-05
20:42
Allocation the mutex used by the Win32 VFS only once at initialization, instead of every time it is needed. check-in: 535ed0ac user: mistachkin tags: trunk
16:39
Allocation the mutex used by the unix VFS only once at initialization, instead of every time it is needed. check-in: 5764dc16 user: drh tags: trunk
13:42
Fix another minor problem in walro2.test. check-in: ba0631de user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   692    692   ** is held when required. This function is only used as part of assert() 
   693    693   ** statements. e.g.
   694    694   **
   695    695   **   unixEnterMutex()
   696    696   **     assert( unixMutexHeld() );
   697    697   **   unixEnterLeave()
   698    698   */
          699  +static sqlite3_mutex *unixBigLock = 0;
   699    700   static void unixEnterMutex(void){
   700         -  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
          701  +  sqlite3_mutex_enter(unixBigLock);
   701    702   }
   702    703   static void unixLeaveMutex(void){
   703         -  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
          704  +  sqlite3_mutex_leave(unixBigLock);
   704    705   }
   705    706   #ifdef SQLITE_DEBUG
   706    707   static int unixMutexHeld(void) {
   707         -  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));
          708  +  return sqlite3_mutex_held(unixBigLock);
   708    709   }
   709    710   #endif
   710    711   
   711    712   
   712    713   #ifdef SQLITE_HAVE_OS_TRACE
   713    714   /*
   714    715   ** Helper function for printing out trace information from debugging
................................................................................
  5842   5843     ** the same instant might all reset the PRNG.  But multiple resets
  5843   5844     ** are harmless.
  5844   5845     */
  5845   5846     if( randomnessPid!=osGetpid(0) ){
  5846   5847       randomnessPid = osGetpid(0);
  5847   5848       sqlite3_randomness(0,0);
  5848   5849     }
  5849         -
  5850   5850     memset(p, 0, sizeof(unixFile));
  5851   5851   
  5852   5852     if( eType==SQLITE_OPEN_MAIN_DB ){
  5853   5853       UnixUnusedFd *pUnused;
  5854   5854       pUnused = findReusableFd(zName, flags);
  5855   5855       if( pUnused ){
  5856   5856         fd = pUnused->fd;
................................................................................
  7717   7717     ** correctly.  See ticket [bb3a86e890c8e96ab] */
  7718   7718     assert( ArraySize(aSyscall)==29 );
  7719   7719   
  7720   7720     /* Register all VFSes defined in the aVfs[] array */
  7721   7721     for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
  7722   7722       sqlite3_vfs_register(&aVfs[i], i==0);
  7723   7723     }
         7724  +  unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);
  7724   7725     return SQLITE_OK; 
  7725   7726   }
  7726   7727   
  7727   7728   /*
  7728   7729   ** Shutdown the operating system interface.
  7729   7730   **
  7730   7731   ** Some operating systems might need to do some cleanup in this routine,
  7731   7732   ** to release dynamically allocated objects.  But not on unix.
  7732   7733   ** This routine is a no-op for unix.
  7733   7734   */
  7734   7735   int sqlite3_os_end(void){ 
         7736  +  unixBigLock = 0;
  7735   7737     return SQLITE_OK; 
  7736   7738   }
  7737   7739    
  7738   7740   #endif /* SQLITE_OS_UNIX */