diff options
author | drh <drh@noemail.net> | 2006-02-13 14:49:38 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-02-13 14:49:38 +0000 |
commit | fc8748a7720ecd1cbe88c099f310d89f4fb13816 (patch) | |
tree | 0bd918cb085f827d03dda1793e826b530c339ee8 /src | |
parent | 4b74b26052997d369b2e5af3ad0536b21a520ca6 (diff) | |
download | sqlite-fc8748a7720ecd1cbe88c099f310d89f4fb13816.tar.gz sqlite-fc8748a7720ecd1cbe88c099f310d89f4fb13816.zip |
Improvements to the TRACE macro in test_async.c. (CVS 3088)
FossilOrigin-Name: 4c6dfec54fc128644e066c04902433f8df30672e
Diffstat (limited to 'src')
-rw-r--r-- | src/test_async.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/test_async.c b/src/test_async.c index e88a43d52..ac8bac1f4 100644 --- a/src/test_async.c +++ b/src/test_async.c @@ -106,11 +106,18 @@ typedef struct AsyncFile AsyncFile; /* Enable for debugging */ #if 0 -# define TRACE(X,Y) \ - fprintf(stderr,"THRD=%d: ", (int)pthread_self()); \ - fprintf(stderr,X,Y); +# define TRACE(X) asyncTrace X +static void asyncTrace(const char *zFormat, ...){ + char *z; + va_list ap; + va_start(ap, zFormat); + z = sqlite3_vmprintf(zFormat, ap); + va_end(ap); + fprintf(stderr, "[%d] %s", (int)pthread_self(), z); + free(z); +} #else -# define TRACE(X,Y) /* noop */ +# define TRACE(X) /* noop */ #endif /* @@ -315,7 +322,8 @@ struct AsyncWrite { */ struct AsyncFile { IoMethod *pMethod; /* Must be first */ - int ioError; /* Value of any asychronous error we have seen */ i64 iOffset; /* Current seek() offset in file */ + int ioError; /* Value of any asychronous error we have seen */ + i64 iOffset; /* Current seek() offset in file */ OsFile *pBaseRead; /* Read handle to the underlying Os file */ OsFile *pBaseWrite; /* Write handle to the underlying Os file */ }; @@ -343,7 +351,7 @@ static void addAsyncWrite(AsyncWrite *pWrite){ async.pQueueFirst = pWrite; } async.pQueueLast = pWrite; - TRACE("PUSH %p\n", pWrite); + TRACE(("PUSH %p\n", pWrite)); /* Drop the queue mutex */ pthread_mutex_unlock(&async.queueMutex); @@ -828,13 +836,13 @@ static void *asyncWriterThread(void *NotUsed){ pthread_mutex_unlock(&async.queueMutex); break; }else{ - TRACE("IDLE\n", 0); + TRACE(("IDLE\n")); pthread_cond_wait(&async.queueSignal, &async.queueMutex); - TRACE("WAKEUP\n", 0); + TRACE(("WAKEUP\n")); } } if( p==0 ) break; - TRACE("PROCESSING %p\n", p); + TRACE(("PROCESSING %p\n", p)); /* 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 @@ -957,7 +965,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; } @@ -1116,7 +1124,7 @@ static int testAsyncWait( Tcl_AppendResult(interp, "would block forever", (char*)0); return TCL_ERROR; } - TRACE("WAIT\n",0); + TRACE(("WAIT\n")); pthread_cond_broadcast(&async.queueSignal); pthread_mutex_lock(&async.writerMutex); pthread_mutex_unlock(&async.writerMutex); |