| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2006 January 09 | 2 ** 2006 January 09 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** Code for testing the client/server version of the SQLite library. | 12 ** Code for testing the client/server version of the SQLite library. |
| 13 ** Derived from test4.c. | 13 ** Derived from test4.c. |
| 14 ** | |
| 15 ** $Id: test7.c,v 1.13 2008/10/12 00:27:54 shane Exp $ | |
| 16 */ | 14 */ |
| 17 #include "sqliteInt.h" | 15 #include "sqliteInt.h" |
| 18 #include "tcl.h" | 16 #include "tcl.h" |
| 19 | 17 |
| 20 /* | 18 /* |
| 21 ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes | 19 ** This test only works on UNIX with a SQLITE_THREADSAFE build that includes |
| 22 ** the SQLITE_SERVER option. | 20 ** the SQLITE_SERVER option. |
| 23 */ | 21 */ |
| 24 #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) && \ | 22 #if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) && \ |
| 25 defined(SQLITE_OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE | 23 defined(SQLITE_OS_UNIX) && OS_UNIX && SQLITE_THREADSAFE |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return TCL_ERROR; | 157 return TCL_ERROR; |
| 160 } | 158 } |
| 161 i = parse_client_id(interp, argv[1]); | 159 i = parse_client_id(interp, argv[1]); |
| 162 if( i<0 ) return TCL_ERROR; | 160 if( i<0 ) return TCL_ERROR; |
| 163 if( threadset[i].busy ){ | 161 if( threadset[i].busy ){ |
| 164 Tcl_AppendResult(interp, "thread ", argv[1], " is already running", 0); | 162 Tcl_AppendResult(interp, "thread ", argv[1], " is already running", 0); |
| 165 return TCL_ERROR; | 163 return TCL_ERROR; |
| 166 } | 164 } |
| 167 threadset[i].busy = 1; | 165 threadset[i].busy = 1; |
| 168 sqlite3_free(threadset[i].zFilename); | 166 sqlite3_free(threadset[i].zFilename); |
| 169 threadset[i].zFilename = sqlite3DbStrDup(0, argv[2]); | 167 threadset[i].zFilename = sqlite3_mprintf("%s", argv[2]); |
| 170 threadset[i].opnum = 1; | 168 threadset[i].opnum = 1; |
| 171 threadset[i].completed = 0; | 169 threadset[i].completed = 0; |
| 172 rc = pthread_create(&x, 0, client_main, &threadset[i]); | 170 rc = pthread_create(&x, 0, client_main, &threadset[i]); |
| 173 if( rc ){ | 171 if( rc ){ |
| 174 Tcl_AppendResult(interp, "failed to create the thread", 0); | 172 Tcl_AppendResult(interp, "failed to create the thread", 0); |
| 175 sqlite3_free(threadset[i].zFilename); | 173 sqlite3_free(threadset[i].zFilename); |
| 176 threadset[i].busy = 0; | 174 threadset[i].busy = 0; |
| 177 return TCL_ERROR; | 175 return TCL_ERROR; |
| 178 } | 176 } |
| 179 pthread_detach(x); | 177 pthread_detach(x); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 500 } |
| 503 i = parse_client_id(interp, argv[1]); | 501 i = parse_client_id(interp, argv[1]); |
| 504 if( i<0 ) return TCL_ERROR; | 502 if( i<0 ) return TCL_ERROR; |
| 505 if( !threadset[i].busy ){ | 503 if( !threadset[i].busy ){ |
| 506 Tcl_AppendResult(interp, "no such thread", 0); | 504 Tcl_AppendResult(interp, "no such thread", 0); |
| 507 return TCL_ERROR; | 505 return TCL_ERROR; |
| 508 } | 506 } |
| 509 client_wait(&threadset[i]); | 507 client_wait(&threadset[i]); |
| 510 threadset[i].xOp = do_compile; | 508 threadset[i].xOp = do_compile; |
| 511 sqlite3_free(threadset[i].zArg); | 509 sqlite3_free(threadset[i].zArg); |
| 512 threadset[i].zArg = sqlite3DbStrDup(0, argv[2]); | 510 threadset[i].zArg = sqlite3_mprintf("%s", argv[2]); |
| 513 threadset[i].opnum++; | 511 threadset[i].opnum++; |
| 514 return TCL_OK; | 512 return TCL_OK; |
| 515 } | 513 } |
| 516 | 514 |
| 517 /* | 515 /* |
| 518 ** This procedure runs in the thread to step the virtual machine. | 516 ** This procedure runs in the thread to step the virtual machine. |
| 519 */ | 517 */ |
| 520 static void do_step(Thread *p){ | 518 static void do_step(Thread *p){ |
| 521 int i; | 519 int i; |
| 522 if( p->pStmt==0 ){ | 520 if( p->pStmt==0 ){ |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 int i; | 714 int i; |
| 717 | 715 |
| 718 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ | 716 for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){ |
| 719 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); | 717 Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0); |
| 720 } | 718 } |
| 721 return TCL_OK; | 719 return TCL_OK; |
| 722 } | 720 } |
| 723 #else | 721 #else |
| 724 int Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; } | 722 int Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; } |
| 725 #endif /* SQLITE_OS_UNIX */ | 723 #endif /* SQLITE_OS_UNIX */ |
| OLD | NEW |