pnoltes commented on pull request #226:
URL: https://github.com/apache/celix/pull/226#issuecomment-625163108


   > While this is a nice safeguard, wouldn't it be better to unlock at the 
proper place? On the other hand, since it is destroyed, it doesn't matter much.
   > I guess main concern is, now it is unlocked before destroy, but what if 
something changes, and the specific lock is used in another scenario. Then it 
might result in a deadlock/ub gain.
   > Arguably, we can wait for that to happen, and fix each individual case 
then.
   
   I agree that the locks should be unlock at the proper place. When a destroy 
function is called, the object should not be used anymore or the destroy call 
must arrange it is not used anymore (stop tracker, unregister service).
   I think a assert call is better safeguard and also more semantic, e.g.:
   
   
   ```C
   celixThreadMutex_assertIsNotLocked(&admin->mutex);
   celixThreadMutex_destroy(&admin->mutex);
   ```
   
   Btw the assert call can use a try lock to assert this.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to