I still get occasional AVs in shut down. It is in cacheNode deletion. This is the code:
bool __fastcall ProxyCache::deleteFileFromDiskCacheWRTIndex(DiskFileCache *bufferFileCache, bool alreadyMarkedAsToDelete) { if(!bufferFileCache) return false; if(bufferFileCache->cacheTreeNode) { bufferFileCache->cacheTreeNode->Data = NULL; diskFileCacheIndex->Remove(bufferFileCache->cacheTreeNode); << RANDOM AV HERE! bufferFileCache->cacheTreeNode = NULL; } cacheCurrentDiskSize -= bufferFileCache->getAndZeroSize(); if(!bufferFileCache->getWriteLock() && !bufferFileCache->getIsReadLock()) { bufferFileCache->saveHeaderDataToIniFile(true); delete bufferFileCache; return true; } else { if(!alreadyMarkedAsToDelete) bufferFileCache->setDeleteFileASAP(); return false; } } //-------------------------------------------------------------------------- What I guess is multiple DiskFileCache's are assigned the same cacheNode and it is being deleted twice but not sure. This TCacheTree is not that flexible as it seems... Best Regards, SZ On Tue, Dec 6, 2011 at 17:35, Fastream Technologies <ga...@fastream.com>wrote: > Hi Arno, > > procedure TCacheTree.Insert( > Key : String; > Data : Pointer; > Len : Integer; > TimeStamp : TDateTime = MinDT; > Expires : TDateTime = MinDT; > UpdateTime : Boolean = True; > UpdateData : Boolean = True); > var > CacheNode, > ResNode : TCacheNode; > NewIdx, > ResIdx : TCacheIdxNode; > Found : Boolean; > begin > CacheNode := TCacheNode.Create(Key, Data, Len); > FFoundNode := nil; > ResNode := TCacheNode(SearchAndInsert(CacheNode, Found)); > if not Found then // Primary key not found = new cache Node added > begin > NewIdx := TCacheIdxNode.Create(CacheNode, TimeStamp, Expires); > ResIdx := TCacheIdxNode(FSecIdxTree.SearchAndInsert(NewIdx, > Found)); > if not Found then // New TimeStamp inserted > CacheNode.FIdxRef := NewIdx > else begin // TimeStamp exists, add a duplicate > if not Assigned(ResIdx.FDups) then > begin > ResIdx.FDups := TSecIdxDuplicates.Create; > ResIdx.FDups.InsertEnd(ResIdx); > end; > ResIdx.FDups.InsertEnd(NewIdx); > CacheNode.FIdxRef := NewIdx; > end; > FLastInsertedNode := CacheNode; // Fastream > end > else begin // Primary key found - update data and secondary index > if UpdateData then > begin > // Old data needs to be freed > TriggerFreeData(ResNode.FData, ResNode.FLen); > // Update Data > ResNode.FData := Data; > ResNode.FLen := Len; > end; > if UpdateTime then > begin > //Update TimeStamp (delete and new) > FSecIdxTree.Remove(ResNode.FIdxRef); > NewIdx := TCacheIdxNode.Create(ResNode, TimeStamp, Expires); > ResIdx := TCacheIdxNode(FSecIdxTree.SearchAndInsert(NewIdx, > Found)); > if not Found then > ResNode.FIdxRef := NewIdx > else begin // Time value exists, create a duplicate > if not Assigned(ResIdx.FDups) then > begin > ResIdx.FDups := TSecIdxDuplicates.Create; > ResIdx.FDups.InsertEnd(ResIdx); > end; > ResIdx.FDups.InsertEnd(NewIdx); > ResNode.FIdxRef := NewIdx > end; > end; > FLastInsertedNode := ResNode; // Fastream > // not new > FreeAndNil(CacheNode); > end; > end; > > I think this is better to get the last insertion node. > > Best Regards, > > SZ > On Tue, Dec 6, 2011 at 11:03, Arno Garrels <arno.garr...@gmx.de> wrote: > >> Fastream Technologies wrote: >> > TCacheNode = class(TAvlTreeNode) >> > private >> > FKey : String; >> > FData : Pointer; >> > FLen : Integer; >> > FIdxRef : TCacheIdxNode; >> > public >> > constructor Create(Key: String; Data: Pointer; Len: Integer); >> > destructor Destroy; override; >> > property Key: String read FKey; >> > property Data: Pointer read FData write FData; // could you >> > add this "write FData"?? Fastream >> > property Len: Integer read FLen; >> > property IdxRef: TCacheIdxNode read FIdxRef; >> > end; >> >> Done. >> >> -- >> Arno Garrels >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be >> > > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be