-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
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
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
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;
fprintf(stderr, "[%d] %s", (int)pthread_self(), z);
free(z);
}
-#else
-# define TRACE(X) /* noop */
-#endif
/*
** THREAD SAFETY NOTES
#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.
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);
}
}
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
pthread_mutex_lock(&async.queueMutex);
holdingMutex = 1;
}
- TRACE(("UNLINK %p\n", p));
+ /* TRACE(("UNLINK %p\n", p)); */
if( p==async.pQueueLast ){
async.pQueueLast = 0;
}
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;
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;
}