1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-02 05:54:29 +03:00

Changes to test code to make sure no server threads are left running after server1.test finishes.

FossilOrigin-Name: 1086e00bcaacc88ef2a9dda8a20698b0899ad2f7
This commit is contained in:
dan
2013-10-15 15:35:27 +00:00
parent a703f50d7e
commit cfe111b1f7
4 changed files with 52 additions and 10 deletions

View File

@@ -40,6 +40,7 @@ int sqlite3_client_finalize(sqlite3_stmt*);
int sqlite3_client_close(sqlite3*);
int sqlite3_server_start(void);
int sqlite3_server_stop(void);
void sqlite3_server_start2(int *pnDecr);
/*
** Each thread is controlled by an instance of the following
@@ -68,6 +69,13 @@ struct Thread {
int argc; /* number of columns in result */
const char *argv[100]; /* result columns */
const char *colv[100]; /* result column names */
/* Initialized to 1 by the supervisor thread when the client is
** created, and then deemed read-only to the supervisor thread.
** Is set to 0 by the server thread belonging to this client
** just before it exits.
*/
int nServer; /* Number of server threads running */
};
/*
@@ -175,7 +183,10 @@ static int tcl_client_create(
return TCL_ERROR;
}
pthread_detach(x);
sqlite3_server_start();
if( threadset[i].nServer==0 ){
threadset[i].nServer = 1;
sqlite3_server_start2(&threadset[i].nServer);
}
return TCL_OK;
}
@@ -268,6 +279,11 @@ static int tcl_client_halt(
for(i=0; i<N_THREAD && threadset[i].busy==0; i++){}
if( i>=N_THREAD ){
sqlite3_server_stop();
while( 1 ){
for(i=0; i<N_THREAD && threadset[i].nServer==0; i++);
if( i==N_THREAD ) break;
sched_yield();
}
}
return TCL_OK;
}