SQLite

Check-in [dd3e07cae4]
Login

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

Overview
Comment:Recursive mutexes in os_win.c. (CVS 2969)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dd3e07cae4d0cbd4f8977e1dd11e0103e0e45b75
User & Date: drh 2006-01-18 14:20:17.000
Context
2006-01-18
15:25
Change sqlite3MallocClearFailed() calls to sqlite3ApiExit(), a better API. (CVS 2970) (check-in: e0b022e5b2 user: danielk1977 tags: trunk)
14:20
Recursive mutexes in os_win.c. (CVS 2969) (check-in: dd3e07cae4 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: 8830bbbac8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_win.c.
1064
1065
1066
1067
1068
1069
1070

1071
1072
1073
1074
1075
1076
1077
}

/*
** Static variables used for thread synchronization
*/
static int inMutex = 0;
#ifdef SQLITE_W32_THREADS

  static CRITICAL_SECTION cs;
#endif

/*
** The following pair of routine implement mutual exclusion for
** multi-threaded processes.  Only a single thread is allowed to
** executed code that is surrounded by EnterMutex() and LeaveMutex().







>







1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
}

/*
** Static variables used for thread synchronization
*/
static int inMutex = 0;
#ifdef SQLITE_W32_THREADS
  static HANDLE mutexOwner;
  static CRITICAL_SECTION cs;
#endif

/*
** The following pair of routine implement mutual exclusion for
** multi-threaded processes.  Only a single thread is allowed to
** executed code that is surrounded by EnterMutex() and LeaveMutex().
1088
1089
1090
1091
1092
1093
1094

1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110



1111

1112
1113
1114
1115
1116
1117
1118
      InitializeCriticalSection(&cs);
      isInit = 1;
    }else{
      Sleep(1);
    }
  }
  EnterCriticalSection(&cs);

#endif
  assert( !inMutex );
  inMutex = 1;
}
void sqlite3WinLeaveMutex(){
  assert( inMutex );
  inMutex = 0;
#ifdef SQLITE_W32_THREADS
  LeaveCriticalSection(&cs);
#endif
}

/*
** Return TRUE if we are currently within the mutex and FALSE if not.
*/
int sqlite3WinInMutex(){



  return inMutex;

}


/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime().  This is used for testing.
*/







>

<
|



|









>
>
>

>







1089
1090
1091
1092
1093
1094
1095
1096
1097

1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
      InitializeCriticalSection(&cs);
      isInit = 1;
    }else{
      Sleep(1);
    }
  }
  EnterCriticalSection(&cs);
  mutexOwner = GetCurrentThread();
#endif

  inMutex++;
}
void sqlite3WinLeaveMutex(){
  assert( inMutex );
  inMutex--;
#ifdef SQLITE_W32_THREADS
  LeaveCriticalSection(&cs);
#endif
}

/*
** Return TRUE if we are currently within the mutex and FALSE if not.
*/
int sqlite3WinInMutex(){
#ifdef SQLITE_W32_THREADS
  return inMutex && mutexOwner==GetCurrentThread();
#else
  return inMutex;
#endif
}


/*
** The following variable, if set to a non-zero value, becomes the result
** returned from sqlite3OsCurrentTime().  This is used for testing.
*/