/ Check-in [dd3e07ca]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Recursive mutexes in os_win.c. (CVS 2969)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dd3e07cae4d0cbd4f8977e1dd11e0103e0e45b75
User & Date: drh 2006-01-18 14:20:17
Context
2006-01-18
15:25
Change sqlite3MallocClearFailed() calls to sqlite3ApiExit(), a better API. (CVS 2970) check-in: e0b022e5 user: danielk1977 tags: trunk
14:20
Recursive mutexes in os_win.c. (CVS 2969) check-in: dd3e07ca user: drh tags: trunk
14:06
Convert the unix driver to use a recusive mutex. Similar changes to the windows driver are pending. (CVS 2968) check-in: 8830bbba user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1064   1064   }
  1065   1065   
  1066   1066   /*
  1067   1067   ** Static variables used for thread synchronization
  1068   1068   */
  1069   1069   static int inMutex = 0;
  1070   1070   #ifdef SQLITE_W32_THREADS
         1071  +  static HANDLE mutexOwner;
  1071   1072     static CRITICAL_SECTION cs;
  1072   1073   #endif
  1073   1074   
  1074   1075   /*
  1075   1076   ** The following pair of routine implement mutual exclusion for
  1076   1077   ** multi-threaded processes.  Only a single thread is allowed to
  1077   1078   ** executed code that is surrounded by EnterMutex() and LeaveMutex().
................................................................................
  1088   1089         InitializeCriticalSection(&cs);
  1089   1090         isInit = 1;
  1090   1091       }else{
  1091   1092         Sleep(1);
  1092   1093       }
  1093   1094     }
  1094   1095     EnterCriticalSection(&cs);
         1096  +  mutexOwner = GetCurrentThread();
  1095   1097   #endif
  1096         -  assert( !inMutex );
  1097         -  inMutex = 1;
         1098  +  inMutex++;
  1098   1099   }
  1099   1100   void sqlite3WinLeaveMutex(){
  1100   1101     assert( inMutex );
  1101         -  inMutex = 0;
         1102  +  inMutex--;
  1102   1103   #ifdef SQLITE_W32_THREADS
  1103   1104     LeaveCriticalSection(&cs);
  1104   1105   #endif
  1105   1106   }
  1106   1107   
  1107   1108   /*
  1108   1109   ** Return TRUE if we are currently within the mutex and FALSE if not.
  1109   1110   */
  1110   1111   int sqlite3WinInMutex(){
         1112  +#ifdef SQLITE_W32_THREADS
         1113  +  return inMutex && mutexOwner==GetCurrentThread();
         1114  +#else
  1111   1115     return inMutex;
         1116  +#endif
  1112   1117   }
  1113   1118   
  1114   1119   
  1115   1120   /*
  1116   1121   ** The following variable, if set to a non-zero value, becomes the result
  1117   1122   ** returned from sqlite3OsCurrentTime().  This is used for testing.
  1118   1123   */