Exemplo n.º 1
0
 /** Free up all pages allocated by the log. */
 void free() {
   if (trace.isDebugEnabled()) {
     trace.debug("log free");
   }
   int currentDataPage = 0;
   if (pageOut != null) {
     currentDataPage = pageOut.getCurrentDataPageId();
     pageOut.freeReserved();
   }
   try {
     freeing = true;
     int first = 0;
     int loopDetect = 1024, loopCount = 0;
     PageStreamTrunk.Iterator it = new PageStreamTrunk.Iterator(store, firstTrunkPage);
     while (firstTrunkPage != 0 && firstTrunkPage < store.getPageCount()) {
       PageStreamTrunk t = it.next();
       if (t == null) {
         if (it.canDelete()) {
           store.free(firstTrunkPage, false);
         }
         break;
       }
       if (loopCount++ >= loopDetect) {
         first = t.getPos();
         loopCount = 0;
         loopDetect *= 2;
       } else if (first != 0 && first == t.getPos()) {
         throw DbException.throwInternalError("endless loop at " + t);
       }
       t.free(currentDataPage);
       firstTrunkPage = t.getNextTrunk();
     }
   } finally {
     freeing = false;
   }
 }