persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.cpp
branchRCL_3
changeset 18 3da531bb4329
parent 10 31a8f755b7fe
child 23 26645d81f48d
equal deleted inserted replaced
16:b6ab70c1385f 18:3da531bb4329
   187 
   187 
   188 /**
   188 /**
   189 Performs a compaction step on the database.
   189 Performs a compaction step on the database.
   190 If the number of the free pages is bigger than the number of pages removed in one compaction step,
   190 If the number of the free pages is bigger than the number of pages removed in one compaction step,
   191 the function will reschedule itself for another compaction step.
   191 the function will reschedule itself for another compaction step.
       
   192 If the database file is corrupted, then the function will remove the database entry from the timer queue - 
       
   193 the database won't be compacted anymore.
   192 
   194 
   193 @return KErrNoMemory, an out of memory condition has occurred;
   195 @return KErrNoMemory, an out of memory condition has occurred;
   194                       Note that the function may also return some other database specific 
   196                       Note that the function may also return some other database specific 
   195                       errors categorised as ESqlDbError, and other system-wide error codes.
   197                       errors categorised as ESqlDbError, and other system-wide error codes.
   196 
   198 
   211 	if(err == KErrNone)
   213 	if(err == KErrNone)
   212 		{
   214 		{
   213 		iPageCount -= processedPageCount;
   215 		iPageCount -= processedPageCount;
   214 		__SQLASSERT(iPageCount >= 0, ESqlPanicInternalError);
   216 		__SQLASSERT(iPageCount >= 0, ESqlPanicInternalError);
   215 		}
   217 		}
   216 	if(iPageCount <= 0)
   218 	TBool stopCompaction = err == KSqlErrCorrupt || err == KSqlErrNotDb || err == KErrCorrupt || err == KErrDisMounted;
   217 		{//No more pages to compact. Stop the compacting, move to EInactive state, remove from the timer queue.
   219 	if(iPageCount <= 0 || stopCompaction)
       
   220 		{//No more pages to compact or the file is corrupted . Stop the compacting, move to EInactive state, remove from the timer queue.
   218 		ResetState();
   221 		ResetState();
   219 		iTimer.DeQueue(*this);
   222 		iTimer.DeQueue(*this);
   220 		}
   223 		}
   221 	SQLCOMPACTENTRY_INVARIANT();
   224 	SQLCOMPACTENTRY_INVARIANT();
   222 	return err;
   225 	return err;