Add comment explaining checksum mechanism.

FossilOrigin-Name: 3e9ef5153ebf0543ad0f75a7561f73d22171da53
This commit is contained in:
dan
2010-04-24 19:07:29 +00:00
parent 74d6cd887f
commit 56d95913eb
3 changed files with 21 additions and 10 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
C Fix\sbugs\sin\sWAL\smode\srollback.
D 2010-04-24T18:44:05
C Add\scomment\sexplaining\schecksum\smechanism.
D 2010-04-24T19:07:29
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4f2f967b7e58a35bb74fb7ec8ae90e0f4ca7868b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -131,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
F src/log.c 6097555f746e9992b3bb7a257d2e60ced69e3a84
F src/log.c 538da9c42f6da426e82b114f37c27cf730fcba34
F src/log.h 06eacedac8b5a720cb88aa3c9e5d886ba7b394fe
F src/main.c 867de6aa444abd97771b2b70472f448d65c1c77e
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
@@ -808,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P a352f6285e33a806fbe4475e720e763fdc5bb47d
R a372a014eac56d1df8e79bcff4ecc6e7
P 31215969f59be536fe87431bb9fbfa7d13027e35
R 1d48ccc5eb3586f62961518732858aa1
U dan
Z 3d8f3676c5fc9fd427fe6aa0aa15e428
Z d82402bdae4dea648cb0a1aad66c722d
+1 -1
View File
@@ -1 +1 @@
31215969f59be536fe87431bb9fbfa7d13027e35
3e9ef5153ebf0543ad0f75a7561f73d22171da53
+14 -3
View File
@@ -316,15 +316,26 @@ static LogSummary *pLogSummary = 0;
** Generate an 8 byte checksum based on the data in array aByte[] and the
** initial values of aCksum[0] and aCksum[1]. The checksum is written into
** aCksum[] before returning.
**
** The range of bytes to checksum is treated as an array of 32-bit
** little-endian unsigned integers. For each integer X in the array, from
** start to finish, do the following:
**
** aCksum[0] += X;
** aCksum[1] += aCksum[0];
**
** For the calculation above, use 64-bit unsigned accumulators. Before
** returning, truncate the values to 32-bits as follows:
**
** aCksum[0] = (u32)(aCksum[0] + (aCksum[0]>>24));
** aCksum[1] = (u32)(aCksum[1] + (aCksum[1]>>24));
*/
#define LOG_CKSM_BYTES 8
static void logChecksumBytes(u8 *aByte, int nByte, u32 *aCksum){
u64 sum1 = aCksum[0];
u64 sum2 = aCksum[1];
u32 *a32 = (u32 *)aByte;
u32 *aEnd = (u32 *)&aByte[nByte];
assert( LOG_CKSM_BYTES==2*sizeof(u32) );
assert( (nByte&0x00000003)==0 );
if( SQLITE_LITTLEENDIAN ){
@@ -1666,7 +1677,7 @@ int sqlite3LogFrames(
PgHdr *pLast; /* Last frame in list */
int nLast = 0; /* Number of extra copies of last page */
assert( LOG_FRAME_HDRSIZE==(4 * 2 + LOG_CKSM_BYTES) );
assert( LOG_FRAME_HDRSIZE==(4 * 2 + 2*sizeof(u32)) );
assert( pList );
/* If this is the first frame written into the log, write the log