From: drh Date: Fri, 5 Jan 2007 01:58:26 +0000 (+0000) Subject: Get threadtest2.c working again after being long neglected. (CVS 3562) X-Git-Tag: version-3.6.10~2606 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba92a2ebadce634d5aa3b84ed92d3ff6026cb0da;p=thirdparty%2Fsqlite.git Get threadtest2.c working again after being long neglected. (CVS 3562) FossilOrigin-Name: 06216d0d3be38bfabda9f5f450a5eaccd20b52b9 --- diff --git a/manifest b/manifest index 775c2e5d6c..5076172947 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sthat\schanged\sdue\sto\s(3560).\s\sTicket\s#2143\s(CVS\s3561) -D 2007-01-05T00:14:28 +C Get\sthreadtest2.c\sworking\sagain\safter\sbeing\slong\sneglected.\s(CVS\s3562) +D 2007-01-05T01:58:27 F Makefile.in 63a71177ed4355c829229affe11167bd28c85884 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -303,7 +303,7 @@ F test/tester.tcl 47670c2d74f466c5b22fca23f9d28cfcc7686452 F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35 F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b -F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b +F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9 F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00 F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368 F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9 @@ -424,7 +424,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P f81c4227c26a4d43993904ab05c1eb9f988e3b66 -R 5769b6df8cac28a7a76311ce66a9c4fc +P c28664d314b8caa2844072ee9e5a50901996dc1e +R d3860e79b5446a0a1dfcf30d4a72043d U drh -Z 94d33ed4b802b7bfa69b01259815f7be +Z c3e34cb4afa4398fa1c661a71381ed9d diff --git a/manifest.uuid b/manifest.uuid index 210229b5c1..9c698bfd67 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c28664d314b8caa2844072ee9e5a50901996dc1e \ No newline at end of file +06216d0d3be38bfabda9f5f450a5eaccd20b52b9 \ No newline at end of file diff --git a/test/threadtest2.c b/test/threadtest2.c index f16fd1a12e..25b1d908d2 100644 --- a/test/threadtest2.c +++ b/test/threadtest2.c @@ -39,12 +39,13 @@ volatile int all_stop = 0; ** global variable to stop all other activity. Print the error message ** or print OK if the string "ok" is seen. */ -int check_callback(void *notUsed, int argc, char **argv, char **notUsed2){ +int check_callback(void *pid, int argc, char **argv, char **notUsed2){ + int id = (int)pid; if( strcmp(argv[0],"ok") ){ all_stop = 1; - fprintf(stderr,"pid=%d. %s\n", getpid(), argv[0]); + fprintf(stderr,"id: %s\n", id, argv[0]); }else{ - /* fprintf(stderr,"pid=%d. OK\n", getpid()); */ + /* fprintf(stderr,"%d: OK\n", id); */ } return 0; } @@ -53,13 +54,13 @@ int check_callback(void *notUsed, int argc, char **argv, char **notUsed2){ ** Do an integrity check on the database. If the first integrity check ** fails, try it a second time. */ -int integrity_check(sqlite *db){ +int integrity_check(sqlite *db, int id){ int rc; if( all_stop ) return 0; - /* fprintf(stderr,"pid=%d: CHECK\n", getpid()); */ + /* fprintf(stderr,"%d: CHECK\n", id); */ rc = sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0); if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ - fprintf(stderr,"pid=%d, Integrity check returns %d\n", getpid(), rc); + fprintf(stderr,"%d, Integrity check returns %d\n", id, rc); } if( all_stop ){ sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0); @@ -70,21 +71,24 @@ int integrity_check(sqlite *db){ /* ** This is the worker thread */ -void *worker(void *notUsed){ +void *worker(void *workerArg){ sqlite *db; + int id = (int)workerArg; int rc; int cnt = 0; + fprintf(stderr, "Starting worker %d\n", id); while( !all_stop && cnt++<10000 ){ - if( cnt%1000==0 ) printf("pid=%d: %d\n", getpid(), cnt); + if( cnt%100==0 ) printf("%d: %d\n", id, cnt); while( (sqlite3_open(DB_FILE, &db))!=SQLITE_OK ) sched_yield(); sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0); - integrity_check(db); + /* integrity_check(db, id); */ if( all_stop ){ sqlite3_close(db); break; } - /* fprintf(stderr, "pid=%d: BEGIN\n", getpid()); */ + /* fprintf(stderr, "%d: BEGIN\n", id); */ rc = sqlite3_exec(db, "INSERT INTO t1 VALUES('bogus data')", 0, 0, 0); - /* fprintf(stderr, "pid=%d: END rc=%d\n", getpid(), rc); */ + /* fprintf(stderr, "%d: END rc=%d\n", id, rc); */ sqlite3_close(db); } + fprintf(stderr, "Worker %d finished\n", id); return 0; } @@ -100,7 +104,7 @@ int main(int argc, char **argv){ char *zJournal = sqlite3_mprintf("%s-journal", DB_FILE); unlink(DB_FILE); unlink(zJournal); - free(zJournal); + sqlite3_free(zJournal); } sqlite3_open(DB_FILE, &db); if( db==0 ){ @@ -114,7 +118,7 @@ int main(int argc, char **argv){ } sqlite3_close(db); for(i=0; i