Remove the mutex from test_multiplex.c.
FossilOrigin-Name: 6374978e8f1ac091394a9f5a1896be92af658bcd
This commit is contained in:
parent
c52496f57f
commit
dadafa881f
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Make\ssure\sleft-join\smarkings\sare\stransferred\sto\sthe\svirtual\sscalar\nsubexpressions\swhen\sdecomposing\sa\svector\scomparison\sin\sthe\sON\sclause\sof\na\sLEFT\sJOIN.\nFix\sfor\sticket\s[fef4bb4bd9185ec8f].
|
||||
D 2016-10-27T01:02:20.511
|
||||
C Remove\sthe\smutex\sfrom\stest_multiplex.c.
|
||||
D 2016-10-27T14:51:02.086
|
||||
F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f
|
||||
@ -425,7 +425,7 @@ F src/test_intarray.h f3b7672f5d1056eac563c0d6ea8480a660b1475c
|
||||
F src/test_journal.c d3b83f2bcb7792c709e57abddc456a2b1818643a
|
||||
F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd
|
||||
F src/test_malloc.c c05f6c40bd6c8bfe5f1718212f81fd5687f91766
|
||||
F src/test_multiplex.c 7c5b218d855cd0505a43185d55283b3fc257c8da
|
||||
F src/test_multiplex.c e054459f7633f3ff8ce1245da724f9a8be189e4e
|
||||
F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635
|
||||
F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a
|
||||
F src/test_onefile.c 416f87a28d6d673352d33fc4b1c7d39db878e50f
|
||||
@ -955,7 +955,7 @@ F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022
|
||||
F test/mmap3.test b3c297e78e6a8520aafcc1a8f140535594c9086e
|
||||
F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93
|
||||
F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
|
||||
F test/multiplex.test efd015ca0b5b4a57dc9535b8feb1273eebeadb60
|
||||
F test/multiplex.test dc0d67b66f84b484a83cb8bbdf3f0a7f49562ccd
|
||||
F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
|
||||
F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
|
||||
F test/multiplex4.test e8ae4c4bd70606a5727743241f13b5701990abe4
|
||||
@ -1528,7 +1528,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 c23f5ef337533c1ec6e3ba78a2910352181cc9ee
|
||||
R 724eaf97bc578ade21f74a2fb4242a1f
|
||||
U drh
|
||||
Z c2d38a18abbe8465fdc3725d309eaa8d
|
||||
P 619f5cc71774a37648e185c8502d7af14eb09b7f
|
||||
R 93e0c879ea55a634df6077f40936fbef
|
||||
U dan
|
||||
Z 9550a31672ece71cb80aa7996bb9624a
|
||||
|
@ -1 +1 @@
|
||||
619f5cc71774a37648e185c8502d7af14eb09b7f
|
||||
6374978e8f1ac091394a9f5a1896be92af658bcd
|
@ -68,19 +68,6 @@
|
||||
#define MAX_PAGE_SIZE 0x10000
|
||||
#define DEFAULT_SECTOR_SIZE 0x1000
|
||||
|
||||
/*
|
||||
** For a build without mutexes, no-op the mutex calls.
|
||||
*/
|
||||
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
|
||||
#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8)
|
||||
#define sqlite3_mutex_free(X)
|
||||
#define sqlite3_mutex_enter(X)
|
||||
#define sqlite3_mutex_try(X) SQLITE_OK
|
||||
#define sqlite3_mutex_leave(X)
|
||||
#define sqlite3_mutex_held(X) ((void)(X),1)
|
||||
#define sqlite3_mutex_notheld(X) ((void)(X),1)
|
||||
#endif /* SQLITE_THREADSAFE==0 */
|
||||
|
||||
/* Maximum chunk number */
|
||||
#define MX_CHUNK_NUMBER 299
|
||||
|
||||
@ -139,7 +126,6 @@ struct multiplexGroup {
|
||||
unsigned int szChunk; /* Chunk size used for this group */
|
||||
unsigned char bEnabled; /* TRUE to use Multiplex VFS for this file */
|
||||
unsigned char bTruncate; /* TRUE to enable truncation of databases */
|
||||
multiplexGroup *pNext, *pPrev; /* Doubly linked list of all group objects */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -187,28 +173,9 @@ static struct {
|
||||
/* True when this shim has been initialized.
|
||||
*/
|
||||
int isInitialized;
|
||||
|
||||
/* For run-time access any of the other global data structures in this
|
||||
** shim, the following mutex must be held. In practice, all this mutex
|
||||
** protects is add/remove operations to/from the linked list of group objects
|
||||
** starting at pGroups below. More specifically, it protects the value of
|
||||
** pGroups itself, and the pNext/pPrev fields of each multiplexGroup
|
||||
** structure. */
|
||||
sqlite3_mutex *pMutex;
|
||||
|
||||
/* List of multiplexGroup objects.
|
||||
*/
|
||||
multiplexGroup *pGroups;
|
||||
} gMultiplex;
|
||||
|
||||
/************************* Utility Routines *********************************/
|
||||
/*
|
||||
** Acquire and release the mutex used to serialize access to the
|
||||
** list of multiplexGroups.
|
||||
*/
|
||||
static void multiplexEnter(void){ sqlite3_mutex_enter(gMultiplex.pMutex); }
|
||||
static void multiplexLeave(void){ sqlite3_mutex_leave(gMultiplex.pMutex); }
|
||||
|
||||
/*
|
||||
** Compute a string length that is limited to what can be stored in
|
||||
** lower 30 bits of a 32-bit signed integer.
|
||||
@ -519,7 +486,6 @@ static int multiplexOpen(
|
||||
/* We need to create a group structure and manage
|
||||
** access to this group of files.
|
||||
*/
|
||||
multiplexEnter();
|
||||
pMultiplexOpen = (multiplexConn*)pConn;
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
@ -626,16 +592,11 @@ static int multiplexOpen(
|
||||
}else{
|
||||
pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;
|
||||
}
|
||||
/* place this group at the head of our list */
|
||||
pGroup->pNext = gMultiplex.pGroups;
|
||||
if( gMultiplex.pGroups ) gMultiplex.pGroups->pPrev = pGroup;
|
||||
gMultiplex.pGroups = pGroup;
|
||||
}else{
|
||||
multiplexFreeComponents(pGroup);
|
||||
sqlite3_free(pGroup);
|
||||
}
|
||||
}
|
||||
multiplexLeave();
|
||||
sqlite3_free(zToFree);
|
||||
return rc;
|
||||
}
|
||||
@ -738,17 +699,8 @@ static int multiplexClose(sqlite3_file *pConn){
|
||||
multiplexConn *p = (multiplexConn*)pConn;
|
||||
multiplexGroup *pGroup = p->pGroup;
|
||||
int rc = SQLITE_OK;
|
||||
multiplexEnter();
|
||||
multiplexFreeComponents(pGroup);
|
||||
/* remove from linked list */
|
||||
if( pGroup->pNext ) pGroup->pNext->pPrev = pGroup->pPrev;
|
||||
if( pGroup->pPrev ){
|
||||
pGroup->pPrev->pNext = pGroup->pNext;
|
||||
}else{
|
||||
gMultiplex.pGroups = pGroup->pNext;
|
||||
}
|
||||
sqlite3_free(pGroup);
|
||||
multiplexLeave();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -845,7 +797,6 @@ static int multiplexTruncate(sqlite3_file *pConn, sqlite3_int64 size){
|
||||
multiplexConn *p = (multiplexConn*)pConn;
|
||||
multiplexGroup *pGroup = p->pGroup;
|
||||
int rc = SQLITE_OK;
|
||||
multiplexEnter();
|
||||
if( !pGroup->bEnabled ){
|
||||
sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);
|
||||
if( pSubOpen==0 ){
|
||||
@ -877,7 +828,6 @@ static int multiplexTruncate(sqlite3_file *pConn, sqlite3_int64 size){
|
||||
}
|
||||
if( rc ) rc = SQLITE_IOERR_TRUNCATE;
|
||||
}
|
||||
multiplexLeave();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -888,7 +838,6 @@ static int multiplexSync(sqlite3_file *pConn, int flags){
|
||||
multiplexGroup *pGroup = p->pGroup;
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
multiplexEnter();
|
||||
for(i=0; i<pGroup->nReal; i++){
|
||||
sqlite3_file *pSubOpen = pGroup->aReal[i].p;
|
||||
if( pSubOpen ){
|
||||
@ -896,7 +845,6 @@ static int multiplexSync(sqlite3_file *pConn, int flags){
|
||||
if( rc2!=SQLITE_OK ) rc = rc2;
|
||||
}
|
||||
}
|
||||
multiplexLeave();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -908,7 +856,6 @@ static int multiplexFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){
|
||||
multiplexGroup *pGroup = p->pGroup;
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
multiplexEnter();
|
||||
if( !pGroup->bEnabled ){
|
||||
sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);
|
||||
if( pSubOpen==0 ){
|
||||
@ -924,7 +871,6 @@ static int multiplexFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){
|
||||
*pSize = i*(sqlite3_int64)pGroup->szChunk + sz;
|
||||
}
|
||||
}
|
||||
multiplexLeave();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1151,11 +1097,6 @@ int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault){
|
||||
pOrigVfs = sqlite3_vfs_find(zOrigVfsName);
|
||||
if( pOrigVfs==0 ) return SQLITE_ERROR;
|
||||
assert( pOrigVfs!=&gMultiplex.sThisVfs );
|
||||
gMultiplex.pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
|
||||
if( !gMultiplex.pMutex ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
gMultiplex.pGroups = NULL;
|
||||
gMultiplex.isInitialized = 1;
|
||||
gMultiplex.pOrigVfs = pOrigVfs;
|
||||
gMultiplex.sThisVfs = *pOrigVfs;
|
||||
@ -1214,14 +1155,7 @@ int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault){
|
||||
int sqlite3_multiplex_shutdown(int eForce){
|
||||
int rc = SQLITE_OK;
|
||||
if( gMultiplex.isInitialized==0 ) return SQLITE_MISUSE;
|
||||
if( gMultiplex.pGroups ){
|
||||
sqlite3_log(SQLITE_MISUSE, "sqlite3_multiplex_shutdown() called "
|
||||
"while database connections are still open");
|
||||
if( !eForce ) return SQLITE_MISUSE;
|
||||
rc = SQLITE_MISUSE;
|
||||
}
|
||||
gMultiplex.isInitialized = 0;
|
||||
sqlite3_mutex_free(gMultiplex.pMutex);
|
||||
sqlite3_vfs_unregister(&gMultiplex.sThisVfs);
|
||||
memset(&gMultiplex, 0, sizeof(gMultiplex));
|
||||
return rc;
|
||||
@ -1299,61 +1233,6 @@ static int SQLITE_TCLAPI test_multiplex_shutdown(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** tclcmd: sqlite3_multiplex_dump
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_multiplex_dump(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
Tcl_Obj *pResult;
|
||||
Tcl_Obj *pGroupTerm;
|
||||
multiplexGroup *pGroup;
|
||||
int i;
|
||||
int nChunks = 0;
|
||||
|
||||
UNUSED_PARAMETER(clientData);
|
||||
UNUSED_PARAMETER(objc);
|
||||
UNUSED_PARAMETER(objv);
|
||||
|
||||
pResult = Tcl_NewObj();
|
||||
multiplexEnter();
|
||||
for(pGroup=gMultiplex.pGroups; pGroup; pGroup=pGroup->pNext){
|
||||
pGroupTerm = Tcl_NewObj();
|
||||
|
||||
if( pGroup->zName ){
|
||||
pGroup->zName[pGroup->nName] = '\0';
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewStringObj(pGroup->zName, -1));
|
||||
}else{
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm, Tcl_NewObj());
|
||||
}
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewIntObj(pGroup->nName));
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewIntObj(pGroup->flags));
|
||||
|
||||
/* count number of chunks with open handles */
|
||||
for(i=0; i<pGroup->nReal; i++){
|
||||
if( pGroup->aReal[i].p!=0 ) nChunks++;
|
||||
}
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewIntObj(nChunks));
|
||||
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewIntObj(pGroup->szChunk));
|
||||
Tcl_ListObjAppendElement(interp, pGroupTerm,
|
||||
Tcl_NewIntObj(pGroup->nReal));
|
||||
|
||||
Tcl_ListObjAppendElement(interp, pResult, pGroupTerm);
|
||||
}
|
||||
multiplexLeave();
|
||||
Tcl_SetObjResult(interp, pResult);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Tclcmd: test_multiplex_control HANDLE DBNAME SUB-COMMAND ?INT-VALUE?
|
||||
*/
|
||||
@ -1428,7 +1307,6 @@ int Sqlitemultiplex_Init(Tcl_Interp *interp){
|
||||
} aCmd[] = {
|
||||
{ "sqlite3_multiplex_initialize", test_multiplex_initialize },
|
||||
{ "sqlite3_multiplex_shutdown", test_multiplex_shutdown },
|
||||
{ "sqlite3_multiplex_dump", test_multiplex_dump },
|
||||
{ "sqlite3_multiplex_control", test_multiplex_control },
|
||||
};
|
||||
int i;
|
||||
|
@ -195,15 +195,16 @@ do_test multiplex-2.3.1 {
|
||||
|
||||
|
||||
unset -nocomplain ::log
|
||||
do_test multiplex-2.4.1 {
|
||||
sqlite3_multiplex_shutdown
|
||||
} {SQLITE_MISUSE}
|
||||
#do_test multiplex-2.4.1 {
|
||||
# sqlite3_multiplex_shutdown
|
||||
#} {SQLITE_MISUSE}
|
||||
do_test multiplex-2.4.2 {
|
||||
execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }
|
||||
} {}
|
||||
do_test multiplex-2.4.3 {
|
||||
set ::log
|
||||
} {SQLITE_MISUSE {sqlite3_multiplex_shutdown() called while database connections are still open}}
|
||||
#do_test multiplex-2.4.3 {
|
||||
# set ::log
|
||||
#} {SQLITE_MISUSE {sqlite3_multiplex_shutdown() called while database connections are still open}}
|
||||
|
||||
do_test multiplex-2.4.4 { file size [multiplex_name test.x 0] } {7168}
|
||||
do_test multiplex-2.4.5 {
|
||||
db close
|
||||
@ -445,11 +446,7 @@ multiplex_set db main 32768 16
|
||||
|
||||
# Return a list of all currently defined multiplexs.
|
||||
proc multiplex_list {} {
|
||||
set allq {}
|
||||
foreach q [sqlite3_multiplex_dump] {
|
||||
lappend allq [lindex $q 0]
|
||||
}
|
||||
return [lsort $allq]
|
||||
glob -nocomplain test2.db*
|
||||
}
|
||||
|
||||
do_test multiplex-4.1.6 {
|
||||
@ -494,7 +491,7 @@ do_test multiplex-4.1.11 {
|
||||
do_test multiplex-4.1.12 {
|
||||
db close
|
||||
multiplex_list
|
||||
} {}
|
||||
} {test2.db}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user