File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,13 @@ void Jrd::Attachment::destroy(Attachment* const attachment)
132132 }
133133
134134 Database* const dbb = attachment->att_database ;
135- attachment->att_delayed_delete .garbageCollect (HazardDelayedDelete::GarbageCollectMethod::GC_FORCE);
136- dbb->dbb_delayed_delete .delayedDelete (attachment->att_delayed_delete .getHazardPointers ());
135+ {
136+ // context scope is needed here for correct GC of hazard pointers
137+ ThreadContextHolder tdbb (dbb, attachment);
138+
139+ attachment->att_delayed_delete .garbageCollect (HazardDelayedDelete::GarbageCollectMethod::GC_FORCE);
140+ dbb->dbb_delayed_delete .delayedDelete (attachment->att_delayed_delete .getHazardPointers ());
141+ }
137142
138143 MemoryPool* const pool = attachment->att_pool ;
139144 Firebird::MemoryStats temp_stats;
Original file line number Diff line number Diff line change @@ -146,7 +146,9 @@ void HazardDelayedDelete::garbageCollect(GarbageCollectMethod gcMethod)
146146 LocalHP localCopy;
147147 localCopy.setSortMode (FB_ARRAY_SORT_MANUAL);
148148 {
149- SyncLockGuard dbbSync (&database->dbb_sync , SYNC_SHARED, FB_FUNCTION);
149+ Sync dbbSync (&database->dbb_sync , FB_FUNCTION);
150+ if (!database->dbb_sync .ourExclusiveLock ())
151+ dbbSync.lock (SYNC_SHARED);
150152
151153 copyHazardPointers (tdbb, localCopy, database->dbb_attachments );
152154 copyHazardPointers (tdbb, localCopy, database->dbb_sys_attachments );
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ class MetadataCache : public Firebird::PermanentStorage
208208 for (FB_SIZE_T pos = 0 ; pos < m_objects.getCount (); ++pos)
209209 {
210210 Hazard<Object> val (tdbb, m_objects[pos]);
211- if (val->getKey () == key)
211+ if (val. hasData () && val ->getKey () == key)
212212 return (SLONG) pos;
213213 }
214214
@@ -341,14 +341,12 @@ class MetadataCache : public Firebird::PermanentStorage
341341
342342 bool getSequence (thread_db* tdbb, SLONG id, MetaName& name)
343343 {
344- GenObject genObj;
345- // !!!!!!!!!!!!!!!! Hazard<GenObject> hp(tdbb, &genObj);
346344 Hazard<GenObject> hp (tdbb);
347345
348346 if (!mdc_generators.load (id, hp))
349347 return false ;
350348
351- name = genObj. value ;
349+ name = hp-> value ;
352350 return true ;
353351 }
354352
You can’t perform that action at this time.
0 commit comments