fix deadlocks on di_close contending with passive scoped dbgi access

This commit is contained in:
Ryan Fleury
2024-05-22 11:54:27 -07:00
parent 0160d05e8a
commit a5e2235fc6
+11 -2
View File
@@ -309,12 +309,19 @@ di_close(String8 path, U64 min_timestamp)
if(node != 0) if(node != 0)
{ {
node->ref_count -= 1; node->ref_count -= 1;
if(node->ref_count == 0) if(node->ref_count == 0) for(;;)
{ {
//- rjf: wait for touch count to go to 0 //- rjf: wait for touch count to go to 0
for(;ins_atomic_u64_eval(&node->touch_count) != 0;){} if(ins_atomic_u64_eval(&node->touch_count) != 0)
{
os_rw_mutex_drop_w(stripe->rw_mutex);
for(U64 start_t = os_now_microseconds(); os_now_microseconds() <= start_t + 250;);
os_rw_mutex_take_w(stripe->rw_mutex);
}
//- rjf: release //- rjf: release
if(node->ref_count == 0 && ins_atomic_u64_eval(&node->touch_count) == 0)
{
di_string_release__stripe_mutex_w_guarded(stripe, node->path); di_string_release__stripe_mutex_w_guarded(stripe, node->path);
if(node->file_base != 0) if(node->file_base != 0)
{ {
@@ -334,6 +341,8 @@ di_close(String8 path, U64 min_timestamp)
} }
DLLRemove(slot->first, slot->last, node); DLLRemove(slot->first, slot->last, node);
SLLStackPush(stripe->free_node, node); SLLStackPush(stripe->free_node, node);
break;
}
} }
} }
} }