Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Changes to test code to make sure no server threads are left running after server1.test finishes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1086e00bcaacc88ef2a9dda8a20698b0 |
User & Date: | dan 2013-10-15 15:35:27.035 |
Context
2013-10-15
| ||
19:06 | Add the "languageid" hidden column to fts4aux. (check-in: 891df358e5 user: dan tags: trunk) | |
15:35 | Changes to test code to make sure no server threads are left running after server1.test finishes. (check-in: 1086e00bca user: dan tags: trunk) | |
14:29 | Fix an 8-byte alignment problem on the "crash test" harness (test code, not in the core) that causes problems on Sparc. (check-in: bcbc65030f user: drh tags: trunk) | |
Changes
Changes to src/test7.c.
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | sqlite3_stmt**,const char**); int sqlite3_client_step(sqlite3_stmt*); int sqlite3_client_reset(sqlite3_stmt*); int sqlite3_client_finalize(sqlite3_stmt*); int sqlite3_client_close(sqlite3*); int sqlite3_server_start(void); int sqlite3_server_stop(void); /* ** Each thread is controlled by an instance of the following ** structure. */ typedef struct Thread Thread; struct Thread { | > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | sqlite3_stmt**,const char**); int sqlite3_client_step(sqlite3_stmt*); int sqlite3_client_reset(sqlite3_stmt*); 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 ** structure. */ typedef struct Thread Thread; struct Thread { |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 | sqlite3_stmt *pStmt; /* Pending operation */ char *zErr; /* operation error */ char *zStaticErr; /* Static error message */ int rc; /* operation return code */ int argc; /* number of columns in result */ const char *argv[100]; /* result columns */ const char *colv[100]; /* result column names */ }; /* ** There can be as many as 26 threads running at once. Each is named ** by a capital letter: A, B, C, ..., Y, Z. */ #define N_THREAD 26 | > > > > > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | sqlite3_stmt *pStmt; /* Pending operation */ char *zErr; /* operation error */ char *zStaticErr; /* Static error message */ int rc; /* operation return code */ 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 */ }; /* ** There can be as many as 26 threads running at once. Each is named ** by a capital letter: A, B, C, ..., Y, Z. */ #define N_THREAD 26 |
︙ | ︙ | |||
171 172 173 174 175 176 177 | if( rc ){ Tcl_AppendResult(interp, "failed to create the thread", 0); sqlite3_free(threadset[i].zFilename); threadset[i].busy = 0; return TCL_ERROR; } pthread_detach(x); | > > | > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | if( rc ){ Tcl_AppendResult(interp, "failed to create the thread", 0); sqlite3_free(threadset[i].zFilename); threadset[i].busy = 0; return TCL_ERROR; } pthread_detach(x); if( threadset[i].nServer==0 ){ threadset[i].nServer = 1; sqlite3_server_start2(&threadset[i].nServer); } return TCL_OK; } /* ** Wait for a thread to reach its idle state. */ static void client_wait(Thread *p){ |
︙ | ︙ | |||
264 265 266 267 268 269 270 271 272 273 274 275 276 277 | stop_thread(&threadset[i]); } /* If no client threads are still running, also stop the server */ for(i=0; i<N_THREAD && threadset[i].busy==0; i++){} if( i>=N_THREAD ){ sqlite3_server_stop(); } return TCL_OK; } /* ** Usage: client_argc ID ** | > > > > > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | stop_thread(&threadset[i]); } /* If no client threads are still running, also stop the server */ 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; } /* ** Usage: client_argc ID ** |
︙ | ︙ |
Changes to src/test_server.c.
︙ | ︙ | |||
467 468 469 470 471 472 473 474 475 476 477 478 479 480 | int rc; g.serverHalt = 0; rc = pthread_create(&x, 0, sqlite3_server, 0); if( rc==0 ){ pthread_detach(x); } } /* ** If a server thread is running, then stop it. If no server is ** running, this routine is effectively a no-op. ** ** This routine waits until the server has actually stopped before ** returning. | > > > > > > > > > > > > > > > > > > > > > > > > > > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | int rc; g.serverHalt = 0; rc = pthread_create(&x, 0, sqlite3_server, 0); if( rc==0 ){ pthread_detach(x); } } /* ** A wrapper around sqlite3_server() that decrements the int variable ** pointed to by the first argument after the sqlite3_server() call ** returns. */ static void *serverWrapper(void *pnDecr){ void *p = sqlite3_server(0); (*(int*)pnDecr)--; return p; } /* ** This function is the similar to sqlite3_server_start(), except that ** the integer pointed to by the first argument is decremented when ** the server thread exits. */ void sqlite3_server_start2(int *pnDecr){ pthread_t x; int rc; g.serverHalt = 0; rc = pthread_create(&x, 0, serverWrapper, (void*)pnDecr); if( rc==0 ){ pthread_detach(x); } } /* ** If a server thread is running, then stop it. If no server is ** running, this routine is effectively a no-op. ** ** This routine waits until the server has actually stopped before ** returning. |
︙ | ︙ |