mirror of
				https://github.com/sqlite/sqlite.git
				synced 2025-11-03 16:53:36 +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:
		
							
								
								
									
										16
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								manifest
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
C Fix\san\s8-byte\salignment\sproblem\son\sthe\s"crash\stest"\sharness\s(test\scode,\nnot\sin\sthe\score)\sthat\scauses\sproblems\son\sSparc.
 | 
					C Changes\sto\stest\scode\sto\smake\ssure\sno\sserver\sthreads\sare\sleft\srunning\safter\sserver1.test\sfinishes.
 | 
				
			||||||
D 2013-10-15T14:29:32.229
 | 
					D 2013-10-15T15:35:27.035
 | 
				
			||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
					F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
				
			||||||
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
 | 
					F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
 | 
				
			||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
					F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
				
			||||||
@@ -234,7 +234,7 @@ F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c
 | 
				
			|||||||
F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df
 | 
					F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df
 | 
				
			||||||
F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013
 | 
					F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013
 | 
				
			||||||
F src/test6.c 00af0fe1947305222b8ed488a69c76c5a2b632e2
 | 
					F src/test6.c 00af0fe1947305222b8ed488a69c76c5a2b632e2
 | 
				
			||||||
F src/test7.c 126b886b53f0358b92aba9b81d3fcbfbe9a93cd6
 | 
					F src/test7.c 72b732baa5642f795655ba1126ea032af46ecfd2
 | 
				
			||||||
F src/test8.c c7aab1d9fbbf54fc33d43b73aa24aa55f9eaf534
 | 
					F src/test8.c c7aab1d9fbbf54fc33d43b73aa24aa55f9eaf534
 | 
				
			||||||
F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
 | 
					F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
 | 
				
			||||||
F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8
 | 
					F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8
 | 
				
			||||||
@@ -263,7 +263,7 @@ F src/test_quota.c 30c64f0ef84734f2231a686df41ed882b0c59bc0
 | 
				
			|||||||
F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb
 | 
					F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb
 | 
				
			||||||
F src/test_rtree.c f3d1d12538dccb75fd916e3fa58f250edbdd3b47
 | 
					F src/test_rtree.c f3d1d12538dccb75fd916e3fa58f250edbdd3b47
 | 
				
			||||||
F src/test_schema.c cd12a2223c3a394f4d07bb93bdf6d344c5c121b6
 | 
					F src/test_schema.c cd12a2223c3a394f4d07bb93bdf6d344c5c121b6
 | 
				
			||||||
F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f
 | 
					F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe
 | 
				
			||||||
F src/test_sqllog.c c1c1bbedbcaf82b93d83e4f9dd990e62476a680e
 | 
					F src/test_sqllog.c c1c1bbedbcaf82b93d83e4f9dd990e62476a680e
 | 
				
			||||||
F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935
 | 
					F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935
 | 
				
			||||||
F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
 | 
					F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd
 | 
				
			||||||
@@ -1125,7 +1125,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 | 
				
			|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
					F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
				
			||||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 | 
					F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 | 
				
			||||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
 | 
					F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
 | 
				
			||||||
P c9c1f8d6701b0a1bc939a7e35e565d4160dbf8d3
 | 
					P bcbc65030fa7c61f94100142e94ba2a5774f85b0
 | 
				
			||||||
R 3bb2d5b093a82403e2bfb9d1fae23d90
 | 
					R f33feda2582cfad813fcab88c99564f2
 | 
				
			||||||
U drh
 | 
					U dan
 | 
				
			||||||
Z 4d64bb39b57c14de71d5cefa2c9bba0a
 | 
					Z 117b667e81ae101d694479399cf015f3
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
bcbc65030fa7c61f94100142e94ba2a5774f85b0
 | 
					1086e00bcaacc88ef2a9dda8a20698b0899ad2f7
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/test7.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/test7.c
									
									
									
									
									
								
							@@ -40,6 +40,7 @@ int sqlite3_client_finalize(sqlite3_stmt*);
 | 
				
			|||||||
int sqlite3_client_close(sqlite3*);
 | 
					int sqlite3_client_close(sqlite3*);
 | 
				
			||||||
int sqlite3_server_start(void);
 | 
					int sqlite3_server_start(void);
 | 
				
			||||||
int sqlite3_server_stop(void);
 | 
					int sqlite3_server_stop(void);
 | 
				
			||||||
 | 
					void sqlite3_server_start2(int *pnDecr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
** Each thread is controlled by an instance of the following
 | 
					** Each thread is controlled by an instance of the following
 | 
				
			||||||
@@ -68,6 +69,13 @@ struct Thread {
 | 
				
			|||||||
  int argc;                /* number of columns in result */
 | 
					  int argc;                /* number of columns in result */
 | 
				
			||||||
  const char *argv[100];   /* result columns */
 | 
					  const char *argv[100];   /* result columns */
 | 
				
			||||||
  const char *colv[100];   /* result column names */
 | 
					  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;
 | 
					    return TCL_ERROR;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  pthread_detach(x);
 | 
					  pthread_detach(x);
 | 
				
			||||||
  sqlite3_server_start();
 | 
					  if( threadset[i].nServer==0 ){
 | 
				
			||||||
 | 
					    threadset[i].nServer = 1;
 | 
				
			||||||
 | 
					    sqlite3_server_start2(&threadset[i].nServer);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  return TCL_OK;
 | 
					  return TCL_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -268,6 +279,11 @@ static int tcl_client_halt(
 | 
				
			|||||||
  for(i=0; i<N_THREAD && threadset[i].busy==0; i++){}
 | 
					  for(i=0; i<N_THREAD && threadset[i].busy==0; i++){}
 | 
				
			||||||
  if( i>=N_THREAD ){
 | 
					  if( i>=N_THREAD ){
 | 
				
			||||||
    sqlite3_server_stop();
 | 
					    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;
 | 
					  return TCL_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -472,6 +472,32 @@ void sqlite3_server_start(void){
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					** 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
 | 
					** If a server thread is running, then stop it.  If no server is
 | 
				
			||||||
** running, this routine is effectively a no-op.
 | 
					** running, this routine is effectively a no-op.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user