Simplifications to the memjournal.c logic to facilitate testing.
FossilOrigin-Name: 8baa2c2c7698e03418531482a8314a5d7ae2c7d3
This commit is contained in:
parent
769b4c95ca
commit
d93b2b840d
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Move\sthe\swrite\sfailure\stest\sin\smemjrnlCreateFile()\sto\sjust\safter\sthe\nactual\swrite,\sthus\sreducing\sthe\snumber\sof\sinstances\sof\sthe\stest\sby\sone.
|
||||
D 2016-03-09T03:44:32.424
|
||||
C Simplifications\sto\sthe\smemjournal.c\slogic\sto\sfacilitate\stesting.
|
||||
D 2016-03-09T04:17:17.100
|
||||
F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
|
||||
@ -321,7 +321,7 @@ F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b
|
||||
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
|
||||
F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
|
||||
F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
|
||||
F src/memjournal.c 13ae08696117438e7fa2518af71e52ee00c02395
|
||||
F src/memjournal.c 6423a0817ffd8c7a04ef9e5fb974b6b9dd71f8b6
|
||||
F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495
|
||||
F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c
|
||||
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
|
||||
@ -1455,7 +1455,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 fa20dcb03b92be3bb32f8e3d6f88681ace3f6c84
|
||||
R ddfc9f5547c4cd989efbf516628daef2
|
||||
P 7f00d80c63b15376391f661d872f2b29a970702d
|
||||
R 3dfe324883f59e455687da1f2d0dc6fa
|
||||
U drh
|
||||
Z f80415911853dbc4f72e4c714eb20705
|
||||
Z 09a89868e4ca6983fd083bec8c9845f2
|
||||
|
@ -1 +1 @@
|
||||
7f00d80c63b15376391f661d872f2b29a970702d
|
||||
8baa2c2c7698e03418531482a8314a5d7ae2c7d3
|
@ -82,38 +82,41 @@ static int memjrnlRead(
|
||||
sqlite_int64 iOfst /* Begin reading at this offset */
|
||||
){
|
||||
MemJournal *p = (MemJournal *)pJfd;
|
||||
u8 *zOut = zBuf;
|
||||
int nRead = iAmt;
|
||||
int iChunkOffset;
|
||||
FileChunk *pChunk;
|
||||
|
||||
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
|
||||
if( (iAmt+iOfst)>p->endpoint.iOffset ){
|
||||
return SQLITE_IOERR_SHORT_READ;
|
||||
}else{
|
||||
u8 *zOut = zBuf;
|
||||
int nRead = iAmt;
|
||||
int iChunkOffset;
|
||||
FileChunk *pChunk;
|
||||
|
||||
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
|
||||
sqlite3_int64 iOff = 0;
|
||||
for(pChunk=p->pFirst;
|
||||
ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
|
||||
pChunk=pChunk->pNext
|
||||
){
|
||||
iOff += p->nChunkSize;
|
||||
}
|
||||
}else{
|
||||
pChunk = p->readpoint.pChunk;
|
||||
}
|
||||
|
||||
iChunkOffset = (int)(iOfst%p->nChunkSize);
|
||||
do {
|
||||
int iSpace = p->nChunkSize - iChunkOffset;
|
||||
int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));
|
||||
memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);
|
||||
zOut += nCopy;
|
||||
nRead -= iSpace;
|
||||
iChunkOffset = 0;
|
||||
} while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
|
||||
p->readpoint.iOffset = iOfst+iAmt;
|
||||
p->readpoint.pChunk = pChunk;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert( (iAmt+iOfst)<=p->endpoint.iOffset );
|
||||
if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
|
||||
sqlite3_int64 iOff = 0;
|
||||
for(pChunk=p->pFirst;
|
||||
ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
|
||||
pChunk=pChunk->pNext
|
||||
){
|
||||
iOff += p->nChunkSize;
|
||||
}
|
||||
}else{
|
||||
pChunk = p->readpoint.pChunk;
|
||||
}
|
||||
|
||||
iChunkOffset = (int)(iOfst%p->nChunkSize);
|
||||
do {
|
||||
int iSpace = p->nChunkSize - iChunkOffset;
|
||||
int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));
|
||||
memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);
|
||||
zOut += nCopy;
|
||||
nRead -= iSpace;
|
||||
iChunkOffset = 0;
|
||||
} while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
|
||||
p->readpoint.iOffset = iOfst+iAmt;
|
||||
p->readpoint.pChunk = pChunk;
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@ -146,14 +149,12 @@ static int memjrnlCreateFile(MemJournal *p){
|
||||
i64 iOff = 0;
|
||||
FileChunk *pIter;
|
||||
for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){
|
||||
int nWrite = nChunk;
|
||||
if( pIter==copy.endpoint.pChunk ){
|
||||
nWrite = copy.endpoint.iOffset % copy.nChunkSize;
|
||||
if( nWrite==0 ) nWrite = copy.nChunkSize;
|
||||
if( iOff + nChunk > copy.endpoint.iOffset ){
|
||||
nChunk = copy.endpoint.iOffset - iOff;
|
||||
}
|
||||
rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nWrite, iOff);
|
||||
rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);
|
||||
if( rc ) break;
|
||||
iOff += nWrite;
|
||||
iOff += nChunk;
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
/* No error has occurred. Free the in-memory buffers. */
|
||||
|
Loading…
Reference in New Issue
Block a user