svn commit: r262806 - head/sys/net

Gleb Smirnoff glebius at FreeBSD.org
Wed Mar 5 23:35:06 UTC 2014


On Wed, Mar 05, 2014 at 03:29:55PM -0800, Adrian Chadd wrote:
A> ... why's the code returning locked mutexes to UMA?
A> 
A> Why not fix the places that are doing this and doing a lock assertion
A> in the destructor? What's this buy us?
A> 
A> I'm very wary of design patterns like this that do conditional
A> unlocking in free/destructor routines; it allows for the caller to not
A> necessarily get all the lock/unlock stuff to line up in the main code
A> and it can make debugging more of a pain.

I get your point, and even share it. I discussed that with melifaro@,
he prefers destructors being smart. Note that mutex(9) by design allows
to destroy a locked mutex. And route(4) relied on this semantics. Now
I converted route(4) to lazy mutex deallocation. Of course, if mutex(9)
didn't allow such trick, I wouldn't implement the code I did. But since
code of route(4) was not considered broken before, I decided to keep
status quo.


-- 
Totus tuus, Glebius.


More information about the svn-src-all mailing list