diff options
author | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 |
---|---|---|
committer | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 |
commit | 9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch) | |
tree | c88a33f01f20a3d13a09594f114fffacebd0d1a4 /src/test7.c | |
parent | ee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff) | |
parent | 569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff) |
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0
# gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81
# gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>"
# gpg: aka "Hans-Christoph Steiner <hans@eds.org>"
# gpg: aka "Hans-Christoph Steiner <hans@at.or.at>"
# gpg: aka "[jpeg image of size 5408]"
Diffstat (limited to 'src/test7.c')
-rw-r--r-- | src/test7.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/test7.c b/src/test7.c index 3cd4a22..93bf1e4 100644 --- a/src/test7.c +++ b/src/test7.c @@ -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; } |