View Single Post
Old 09 August 2021, 11:01   #22
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,249
...and there you have it. Checked your code, you now have a race condition thanks to semaphores. First, what does the semaphore exactly protect? Anything it protects in LibOpen can go away without getting the semaphore in LibClose(), so it's not exactly helping, right?

Second, a task could remove your library while the semaphore is blocked. You need to increment the lib Open counter *outside* of the semaphore as this counter protects the library from going away *while* the semaphore is blocked.

Then, as said, you need to get LibClose() right to work with the semaphore.

As I said, avoid this... Think twice where a task could block, and what could happen in parallel while the semaphore is blocked.
Thomas Richter is offline  
 
Page generated in 0.04262 seconds with 10 queries