]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix bugs in test program tserver.c. server-edition
authordan <dan@noemail.net>
Wed, 28 Jun 2017 20:12:41 +0000 (20:12 +0000)
committerdan <dan@noemail.net>
Wed, 28 Jun 2017 20:12:41 +0000 (20:12 +0000)
FossilOrigin-Name: 093b9108ea3532437683547c82f756df2413013a50a2fddad3d928cf8d74f9eb

manifest
manifest.uuid
tool/tserver.c

index e6d8b502def6e80b0dc2858bd0d4c24531b0384d..625a7e4e86d7af4c69f5f92cb6c779e7cb1caf29 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Ensure\sthat\stest\stool\s"tserver"\sfinalizes\sall\sstatements\sbefore\sattempting\sto\nclose\sa\sdatabase\shandle.
-D 2017-06-20T19:20:07.502
+C Fix\sbugs\sin\stest\sprogram\stserver.c.
+D 2017-06-28T20:12:41.779
 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6
@@ -1557,7 +1557,7 @@ F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
 F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
 F tool/symbols.sh c5a617b8c61a0926747a56c65f5671ef8ac0e148
 F tool/tostr.tcl 96022f35ada2194f6f8ccf6fd95809e90ed277c4
-F tool/tserver.c 4596a21376c7632b430510b184911b60dfa2cd2167c4a2252371dcbafbdf752e
+F tool/tserver.c 8067d85410c827c9d1b33fd3f269b96615ab404a277c268e1838bfa768b58949
 F tool/varint.c 5d94cb5003db9dbbcbcc5df08d66f16071aee003
 F tool/vdbe-compress.tcl 5926c71f9c12d2ab73ef35c29376e756eb68361c
 F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
@@ -1585,7 +1585,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 05b4fc4340011847c8585bb822d339dd7b8351266a12b26fdc85edce38fc9dd3
-R 5abfa2b3bda91a8770a53a2957396fde
+P d8568aacf083b63cdcf68d744ddb07a7615d14f169be6c632813a266a1e8a1cf
+R fca1d20100f6bb2d0932053fa9b009ce
 U dan
-Z b4624fe82f09b9b3eec8967be30284e2
+Z abee9fae5ac9c5e9468404f3e0fbaf84
index 719bb96e65db8f609c07f749b3b64d90396ef941..f8a03ca9d1a8e0dbf6d96d8d25faff46b47edb88 100644 (file)
@@ -1 +1 @@
-d8568aacf083b63cdcf68d744ddb07a7615d14f169be6c632813a266a1e8a1cf
\ No newline at end of file
+093b9108ea3532437683547c82f756df2413013a50a2fddad3d928cf8d74f9eb
\ No newline at end of file
index c4dde9fd6592234b79acc1789afac1b574044687..fe237f2c57c5dbb5e9e09bdefb2fb7ddbca8f97d 100644 (file)
@@ -155,6 +155,14 @@ static sqlite3_int64 get_timer(void){
   return ((sqlite3_int64)t.tv_usec / 1000) + ((sqlite3_int64)t.tv_sec * 1000);
 }
 
+static void clear_sql(ClientCtx *p){
+  int j;
+  for(j=0; j<p->nPrepare; j++){
+    sqlite3_finalize(p->apPrepare[j]);
+  }
+  p->nPrepare = 0;
+}
+
 static int handle_dot_command(ClientCtx *p, const char *zCmd, int nCmd){
   assert( zCmd[0]=='.' );
   int n;
@@ -188,6 +196,7 @@ static int handle_dot_command(ClientCtx *p, const char *zCmd, int nCmd){
   else if( n>=2 && n<=7 && 0==strncmp(z, "repeats", n) ){
     if( nArg ){
       p->nRepeat = strtol(zArg, 0, 0);
+      if( p->nRepeat>0 ) p->nSecond = 0;
     }
     rc = send_message(p, "ok (repeat=%d)\n", p->nRepeat);
   }
@@ -235,13 +244,14 @@ static int handle_dot_command(ClientCtx *p, const char *zCmd, int nCmd){
         t1 = t2;
         nT1 = j+1 - nBusy;
         nTBusy1 = nBusy;
-        if( p->nSecond>=0 && (p->nSecond*1000)<=t1-t0 ) break;
+        if( p->nSecond>0 && (p->nSecond*1000)<=t1-t0 ) break;
       }
     }
 
     if( rc==SQLITE_OK ){
       send_message(p, "ok (%d/%d SQLITE_BUSY)\n", nBusy, j);
     }
+    clear_sql(p);
   }
 
   else if( n>=1 && n<=7 && 0==strncmp(z, "seconds", n) ){
@@ -285,7 +295,6 @@ static void *handle_client(void *pArg){
     int i;
     int iStart;
     int nConsume;
-    int bQuote = 0;
     res = read(ctx.fd, &zCmd[nCmd], sizeof(zCmd)-nCmd-1);
     if( res<=0 ) break;
     nCmd += res;
@@ -347,9 +356,7 @@ static void *handle_client(void *pArg){
 
   fprintf(stdout, "Client %d disconnects\n", ctx.fd);
   close(ctx.fd);
-  for(j=0; j<ctx.nPrepare; j++){
-    sqlite3_finalize(ctx.apPrepare[j]);
-  }
+  clear_sql(&ctx);
   sqlite3_free(ctx.apPrepare);
   sqlite3_close(ctx.db);
   return 0;
@@ -361,7 +368,6 @@ int main(int argc, char *argv[]) {
   int rc;
   int yes = 1;
   struct sockaddr_in server;
-  struct sockaddr_in client;
 
   /* Ignore SIGPIPE. Otherwise the server exits if a client disconnects
   ** abruptly.  */