]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a deadlock problem on the sqlite3async_wait test interface. Improvements
authordrh <drh@noemail.net>
Mon, 13 Feb 2006 15:29:32 +0000 (15:29 +0000)
committerdrh <drh@noemail.net>
Mon, 13 Feb 2006 15:29:32 +0000 (15:29 +0000)
to tracing in test_async.c. (CVS 3089)

FossilOrigin-Name: 58c6d501385c6f7656290e8451e28be3fc45843f

manifest
manifest.uuid
src/test_async.c

index ac687d06fbabe6643222f912f73d17427e0fbd37..ce77ca441e15b7693d712e9170ee2460ab27c651 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improvements\sto\sthe\sTRACE\smacro\sin\stest_async.c.\s(CVS\s3088)
-D 2006-02-13T14:49:39
+C Fix\sa\sdeadlock\sproblem\son\sthe\ssqlite3async_wait\stest\sinterface.\s\sImprovements\nto\stracing\sin\stest_async.c.\s(CVS\s3089)
+D 2006-02-13T15:29:33
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -80,7 +80,7 @@ F src/test4.c ff4e9406b3d2809966d8f0e82468ac5508be9f56
 F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
 F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
 F src/test7.c d28d3e62f9594923648fc6a8fb030eba36564ba1
-F src/test_async.c 54636b981b4fd713fc43431643533ebda01c3549
+F src/test_async.c b721c7cfcf40374a5e88d0ccd99d6354c7e5e258
 F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
 F src/test_server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
 F src/tokenize.c 382b3bb0ca26eb9153b5d20b246ef512a114a24f
@@ -352,7 +352,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 4366e7121703a18ebb799dfa4f168b3b2508604e
-R 452100386a2d4ef89296f723a0e64f5d
+P 4c6dfec54fc128644e066c04902433f8df30672e
+R 0f06f2bb71d391db7d343449491e5029
 U drh
-Z 9b2e039e9fbfb0544c06b3d486f0c601
+Z 257635654268c39c1b6895d7785df9c1
index b489fa0dc37da11551468c89916672fe8f54a840..ff9801566c6df72ea9019f1bedfb2c8f34c5c576 100644 (file)
@@ -1 +1 @@
-4c6dfec54fc128644e066c04902433f8df30672e
\ No newline at end of file
+58c6d501385c6f7656290e8451e28be3fc45843f
\ No newline at end of file
index ac8bac1f4358cb646cd84b78d57b95e97b8834c1..989ab27c192d63d63604a6035b5be06dc5e4db74 100644 (file)
@@ -105,8 +105,8 @@ typedef struct AsyncWrite AsyncWrite;
 typedef struct AsyncFile AsyncFile;
 
 /* Enable for debugging */
-#if 0
-# define TRACE(X) asyncTrace X
+static int sqlite3async_trace = 0;
+# define TRACE(X) if( sqlite3async_trace ) asyncTrace X
 static void asyncTrace(const char *zFormat, ...){
   char *z;
   va_list ap;
@@ -116,9 +116,6 @@ static void asyncTrace(const char *zFormat, ...){
   fprintf(stderr, "[%d] %s", (int)pthread_self(), z);
   free(z);
 }
-#else
-# define TRACE(X) /* noop */
-#endif
 
 /*
 ** THREAD SAFETY NOTES
@@ -263,6 +260,14 @@ static struct TestAsyncStaticData {
 #define ASYNC_OPENEXCLUSIVE 8
 #define ASYNC_SYNCDIRECTORY 9
 
+/* Names of opcodes.  Used for debugging only.
+** Make sure these stay in sync with the macros above!
+*/
+static const char *azOpcodeName[] = {
+  "NOOP", "WRITE", "SYNC", "TRUNCATE", "CLOSE",
+  "OPENDIR", "SETFULLSYNC", "DELETE", "OPENEX", "SYNCDIR"
+};
+
 /*
 ** Entries on the write-op queue are instances of the AsyncWrite
 ** structure, defined here.
@@ -351,7 +356,7 @@ static void addAsyncWrite(AsyncWrite *pWrite){
     async.pQueueFirst = pWrite;
   }
   async.pQueueLast = pWrite;
-  TRACE(("PUSH %p\n", pWrite));
+  TRACE(("PUSH %p (%s)\n", pWrite, azOpcodeName[pWrite->op]));
 
   /* Drop the queue mutex */
   pthread_mutex_unlock(&async.queueMutex);
@@ -842,7 +847,7 @@ static void *asyncWriterThread(void *NotUsed){
       }
     }
     if( p==0 ) break;
-    TRACE(("PROCESSING %p\n", p));
+    TRACE(("PROCESSING %p (%s)\n", p, azOpcodeName[p->op]));
 
     /* Right now this thread is holding the mutex on the write-op queue.
     ** Variable 'p' points to the first entry in the write-op queue. In
@@ -965,7 +970,7 @@ static void *asyncWriterThread(void *NotUsed){
       pthread_mutex_lock(&async.queueMutex);
       holdingMutex = 1;
     }
-    TRACE(("UNLINK %p\n", p));
+    /* TRACE(("UNLINK %p\n", p)); */
     if( p==async.pQueueLast ){
       async.pQueueLast = 0;
     }
@@ -1125,7 +1130,9 @@ static int testAsyncWait(
     return TCL_ERROR;
   }
   TRACE(("WAIT\n"));
+  pthread_mutex_lock(&async.queueMutex);
   pthread_cond_broadcast(&async.queueSignal);
+  pthread_mutex_unlock(&async.queueMutex);
   pthread_mutex_lock(&async.writerMutex);
   pthread_mutex_unlock(&async.writerMutex);
   return TCL_OK;
@@ -1146,6 +1153,8 @@ int Sqlitetestasync_Init(Tcl_Interp *interp){
   Tcl_CreateObjCommand(interp,"sqlite3async_delay",testAsyncDelay,0,0);
   Tcl_CreateObjCommand(interp,"sqlite3async_start",testAsyncStart,0,0);
   Tcl_CreateObjCommand(interp,"sqlite3async_wait",testAsyncWait,0,0);
+  Tcl_LinkVar(interp, "sqlite3async_trace",
+      (char*)&sqlite3async_trace, TCL_LINK_INT);
 #endif  /* OS_UNIX and THREADSAFE and defined(SQLITE_ENABLE_REDEF_IO) */
   return TCL_OK;
 }