On 08/07/2019, kefu chai wrote: [snip] > hi Patrick and list, > but i realized that we are also using Mutex::is_locked_by_me() in > functional code which won't be optimised out. for instance, in > MDSRank::MDSRank() we check "mds_lock.is_locked_by_me()", if it's > true, we just `handle_write_error(r)` without acquiring the lock, > otherwise, we will call this function within `mds_lock`. the same > applies to `MDSDaemon::handle_conf_change()`. so i am wondering if > it's okay to change `mds_lock` to a recursive lock, so we don't need > to query this information from > the mutex. [snip] When I've converted code doing that, I've passed in a std::unique_lock reference in to the function so it could inspect/modify the hold the caller has on the lock. I'd use a recurisve mutex if there's likely to be a lot of functions called between where the mutex is acquired and where we care about whether it has been acquired to avoid having to pass them around between lots of unrelated functions, though. -- Adam C. Emerson https://people.redhat.com/~aemerson/ Senior Software Engineer, Red Hat Storage they/them/their aemerson@xxxxxxxxxx IRC: Aemerson{RedHat,OFTC}, Actinic@Freenode 0x80F7544B90EDBFB9 E707 86BA 0C1B 62CC 152C 7C12 80F7 544B 90ED BFB9 _______________________________________________ Dev mailing list -- dev@xxxxxxx To unsubscribe send an email to dev-leave@xxxxxxx