]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a race condtion in test_async.c. (CVS 4516)
authordanielk1977 <danielk1977@noemail.net>
Tue, 30 Oct 2007 15:29:42 +0000 (15:29 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 30 Oct 2007 15:29:42 +0000 (15:29 +0000)
FossilOrigin-Name: 5e3f7c3dec3e8d92b28a74293387b390fe6fc1fa

manifest
manifest.uuid
src/test_async.c

index 4953ab78e3c836f20fde063c691d6991d277b7ec..1fc3910ec02c8840f4d3b19436011a50558439b8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Clarify\sthe\sbehavior\sof\ssqlite3_last_insert_rowid()\swhen\susing\nINSERT\sOR\sIGNORE.\s(CVS\s4515)
-D 2007-10-27T16:25:16
+C Fix\sa\srace\scondtion\sin\stest_async.c.\s(CVS\s4516)
+D 2007-10-30T15:29:43
 F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -146,7 +146,7 @@ F src/test6.c a9fc983d32d6f262eab300d742e49ff239b0bdbd
 F src/test7.c acec2256c7c2d279db5a8b5fa1a2a68fcc942c67
 F src/test8.c f113aa3723a52113d0fa7c28155ecd37e7e04077
 F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f
-F src/test_async.c c5ea222c2bb0c3c33ab910d1b82622655dd50684
+F src/test_async.c b273b3dc31712b2274815766c360a2bad907b8ab
 F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
 F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
 F src/test_config.c fd6ba4c62dd943e794f00f6ea1e9e32d97bf27f1
@@ -584,7 +584,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P deb8f56d3adea0025d28b8effabec7c7b7fe3026
-R 27a5740f77270c1f94cbbc07f45db7e7
-U drh
-Z 09d045b0cf9283304b9f062260162563
+P c0fa0c8ba80f4cd60bd06da7a032c6424ffd16f8
+R 78bd8c196220170b3b4010cbc5e84b4f
+U danielk1977
+Z 9f1f861b176142b510f4edd5799736a8
index 52ad2d8271fecb11cd39e246ff54d3172507f21b..1054acf18f04e0ee41fed21b50ceb3cdc170b795 100644 (file)
@@ -1 +1 @@
-c0fa0c8ba80f4cd60bd06da7a032c6424ffd16f8
\ No newline at end of file
+5e3f7c3dec3e8d92b28a74293387b390fe6fc1fa
\ No newline at end of file
index b01822371a8fb3af42b46f683c11321cc638aa35..380bfcdba715f7d52bded9380f36ef83346179ea 100644 (file)
@@ -1151,7 +1151,7 @@ static void asyncEnable(int enable){
 **
 ** Only one instance of this procedure may be running at a time.
 */
-static void *asyncWriterThread(void *NotUsed){
+static void *asyncWriterThread(void *pIsStarted){
   sqlite3_vfs *pVfs = (sqlite3_vfs *)(async_vfs.pAppData);
   AsyncWrite *p = 0;
   int rc = SQLITE_OK;
@@ -1160,6 +1160,7 @@ static void *asyncWriterThread(void *NotUsed){
   if( pthread_mutex_trylock(&async.writerMutex) ){
     return 0;
   }
+  (*(int *)pIsStarted) = 1;
   while( async.writerHaltNow==0 ){
     int doNotFree = 0;
     sqlite3_file *pBase = 0;
@@ -1473,12 +1474,16 @@ static int testAsyncStart(
 ){
   pthread_t x;
   int rc;
-  rc = pthread_create(&x, 0, asyncWriterThread, 0);
+  volatile int isStarted = 0;
+  rc = pthread_create(&x, 0, asyncWriterThread, &isStarted);
   if( rc ){
     Tcl_AppendResult(interp, "failed to create the thread", 0);
     return TCL_ERROR;
   }
   pthread_detach(x);
+  while( isStarted==0 ){
+    sched_yield();
+  }
   return TCL_OK;
 }
 
@@ -1497,6 +1502,7 @@ static int testAsyncWait(
   Tcl_Obj *CONST objv[]
 ){
   int cnt = 10;
+  assert(async.writerHaltNow==0);
   if( async.writerHaltNow==0 && async.writerHaltWhenIdle==0 ){
     Tcl_AppendResult(interp, "would block forever", (char*)0);
     return TCL_ERROR;