File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1001,19 +1001,33 @@ void Rtr::setupInlineBlob(const P_INLINE_BLOB* p_blob)
10011001 }
10021002
10031003 blb->rbl_blob_id = p_blob->p_blob_id ;
1004- if (const Rbl* old = rtr_blobs.locate (blb->rbl_blob_id ))
1004+
1005+ for (Rbl* old = rtr_blobs.locate (p_blob->p_blob_id );
1006+ old && (old->rbl_blob_id == p_blob->p_blob_id );)
10051007 {
1008+ fb_assert (blb != old);
1009+
10061010 // Blob with the same blob id already exists. It could be in use, or it
10071011 // could be opened by user explicitly with custom BPB - thus delete new one.
1012+ if (!(old->rbl_flags & Rbl::CACHED ) || (old->rbl_flags & Rbl::USED ))
1013+ {
1014+ delete blb;
1015+ rtr_rdb->decBlobCache (cachedSize);
1016+ return ;
1017+ }
10081018
1009- fb_assert (blb != old);
1010- delete blb;
1019+ Rbl* next = rtr_blobs.getNext ();
10111020
1012- rtr_rdb->decBlobCache (cachedSize);
1013- return ;
1021+ // Old blob is cached and not used, so we can safely remove it from cache and
1022+ // replace with new fresh one.
1023+ rtr_rdb->decBlobCache (old->getCachedSize ());
1024+ rtr_blobs.remove (old);
1025+ delete old;
1026+
1027+ old = next;
10141028 }
1015- else
1016- rtr_blobs.add (blb);
1029+
1030+ rtr_blobs.add (blb);
10171031
10181032 blb->rbl_info .parseInfo (p_blob->p_blob_info .cstr_length , p_blob->p_blob_info .cstr_address );
10191033
You can’t perform that action at this time.
0 commit comments