This commit fixes the most obvious thread safety issues in RecordHandler. However, from looking at the code, I suspect there are other more difficult to spot issues. For example, here is one (t1 and t2 are independent threads):
t1 - foo_t1 = client.record.getRecord("foo")
t1 - foo_t1.discard() preempts just after if( this.usages <= 0 )
t2 - foo_t2 = client.record.getRecord("foo")
t1 - resumes and finishes foo_t1.discard()
t2 - resumes and is now using a record that had destroy() called on it
Do I understand this correctly? If so, do you have a particular way you'd like to fix it?
This commit fixes the most obvious thread safety issues in
RecordHandler
. However, from looking at the code, I suspect there are other more difficult to spot issues. For example, here is one (t1
andt2
are independent threads):t1 -
foo_t1 = client.record.getRecord("foo")
t1 -foo_t1.discard()
preempts just afterif( this.usages <= 0 )
t2 -foo_t2 = client.record.getRecord("foo")
t1 - resumes and finishesfoo_t1.discard()
t2 - resumes and is now using a record that haddestroy()
called on itDo I understand this correctly? If so, do you have a particular way you'd like to fix it?