mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Get threadtest2.c working again after being long neglected. (CVS 3562)
FossilOrigin-Name: 06216d0d3be38bfabda9f5f450a5eaccd20b52b9
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sa\stest\scase\sthat\schanged\sdue\sto\s(3560).\s\sTicket\s#2143\s(CVS\s3561)
|
C Get\sthreadtest2.c\sworking\sagain\safter\sbeing\slong\sneglected.\s(CVS\s3562)
|
||||||
D 2007-01-05T00:14:28
|
D 2007-01-05T01:58:27
|
||||||
F Makefile.in 63a71177ed4355c829229affe11167bd28c85884
|
F Makefile.in 63a71177ed4355c829229affe11167bd28c85884
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@@ -303,7 +303,7 @@ F test/tester.tcl 47670c2d74f466c5b22fca23f9d28cfcc7686452
|
|||||||
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
|
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
|
||||||
F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
|
F test/thread2.test 6d7b30102d600f51b4055ee3a5a19228799049fb
|
||||||
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
|
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
|
||||||
F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b
|
F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
|
||||||
F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
|
F test/tkt1435.test f8c52c41de6e5ca02f1845f3a46e18e25cadac00
|
||||||
F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368
|
F test/tkt1443.test bacc311da5c96a227bf8c167e77a30c99f8e8368
|
||||||
F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9
|
F test/tkt1444.test a9d72f9e942708bd82dde6c707da61c489e213e9
|
||||||
@@ -424,7 +424,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||||
P f81c4227c26a4d43993904ab05c1eb9f988e3b66
|
P c28664d314b8caa2844072ee9e5a50901996dc1e
|
||||||
R 5769b6df8cac28a7a76311ce66a9c4fc
|
R d3860e79b5446a0a1dfcf30d4a72043d
|
||||||
U drh
|
U drh
|
||||||
Z 94d33ed4b802b7bfa69b01259815f7be
|
Z c3e34cb4afa4398fa1c661a71381ed9d
|
||||||
|
@@ -1 +1 @@
|
|||||||
c28664d314b8caa2844072ee9e5a50901996dc1e
|
06216d0d3be38bfabda9f5f450a5eaccd20b52b9
|
@@ -39,12 +39,13 @@ volatile int all_stop = 0;
|
|||||||
** global variable to stop all other activity. Print the error message
|
** global variable to stop all other activity. Print the error message
|
||||||
** or print OK if the string "ok" is seen.
|
** 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") ){
|
if( strcmp(argv[0],"ok") ){
|
||||||
all_stop = 1;
|
all_stop = 1;
|
||||||
fprintf(stderr,"pid=%d. %s\n", getpid(), argv[0]);
|
fprintf(stderr,"id: %s\n", id, argv[0]);
|
||||||
}else{
|
}else{
|
||||||
/* fprintf(stderr,"pid=%d. OK\n", getpid()); */
|
/* fprintf(stderr,"%d: OK\n", id); */
|
||||||
}
|
}
|
||||||
return 0;
|
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
|
** Do an integrity check on the database. If the first integrity check
|
||||||
** fails, try it a second time.
|
** fails, try it a second time.
|
||||||
*/
|
*/
|
||||||
int integrity_check(sqlite *db){
|
int integrity_check(sqlite *db, int id){
|
||||||
int rc;
|
int rc;
|
||||||
if( all_stop ) return 0;
|
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);
|
rc = sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
|
||||||
if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
|
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 ){
|
if( all_stop ){
|
||||||
sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
|
sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
|
||||||
@@ -70,21 +71,24 @@ int integrity_check(sqlite *db){
|
|||||||
/*
|
/*
|
||||||
** This is the worker thread
|
** This is the worker thread
|
||||||
*/
|
*/
|
||||||
void *worker(void *notUsed){
|
void *worker(void *workerArg){
|
||||||
sqlite *db;
|
sqlite *db;
|
||||||
|
int id = (int)workerArg;
|
||||||
int rc;
|
int rc;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
fprintf(stderr, "Starting worker %d\n", id);
|
||||||
while( !all_stop && cnt++<10000 ){
|
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();
|
while( (sqlite3_open(DB_FILE, &db))!=SQLITE_OK ) sched_yield();
|
||||||
sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
|
sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
|
||||||
integrity_check(db);
|
/* integrity_check(db, id); */
|
||||||
if( all_stop ){ sqlite3_close(db); break; }
|
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);
|
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);
|
sqlite3_close(db);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "Worker %d finished\n", id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +104,7 @@ int main(int argc, char **argv){
|
|||||||
char *zJournal = sqlite3_mprintf("%s-journal", DB_FILE);
|
char *zJournal = sqlite3_mprintf("%s-journal", DB_FILE);
|
||||||
unlink(DB_FILE);
|
unlink(DB_FILE);
|
||||||
unlink(zJournal);
|
unlink(zJournal);
|
||||||
free(zJournal);
|
sqlite3_free(zJournal);
|
||||||
}
|
}
|
||||||
sqlite3_open(DB_FILE, &db);
|
sqlite3_open(DB_FILE, &db);
|
||||||
if( db==0 ){
|
if( db==0 ){
|
||||||
@@ -114,7 +118,7 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){
|
for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){
|
||||||
pthread_create(&aThread[i], 0, worker, 0);
|
pthread_create(&aThread[i], 0, worker, (void*)i);
|
||||||
}
|
}
|
||||||
for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){
|
for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){
|
||||||
pthread_join(aThread[i], 0);
|
pthread_join(aThread[i], 0);
|
||||||
|
Reference in New Issue
Block a user