trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

WEAK_SCOPED_MUTEX_LOCK/WEAK_MUTEX_TRY_LOCK revisited

Open masaori335 opened this issue 1 year ago • 1 comments

WEAK_SCOPED_MUTEX_LOCK and WEAK_MUTEX_TRY_LOCK are introduced to allow the mutex to be a nullptr.

https://github.com/apache/trafficserver/blob/31c15927e66c30566edf5e0e83c6b1bf39e84288/include/iocore/eventsystem/Lock.h#L52-L57

Typical usage is below. https://github.com/apache/trafficserver/blob/31c15927e66c30566edf5e0e83c6b1bf39e84288/src/api/APIHook.cc#L73-L75

However, if we take a look at the Continuation::handleEvent in this case, it has a release assert of the mutex.

https://github.com/apache/trafficserver/blob/31c15927e66c30566edf5e0e83c6b1bf39e84288/include/iocore/eventsystem/Continuation.h#L223-L229

It looks like we don't have reason to use WEAK_ version to allow nullptr in many cases.

masaori335 avatar Feb 27 '24 04:02 masaori335

Hmm, I need to think this through a bit. I'm referencing #5879 to keep track of related PRs.

duke8253 avatar Mar 14 '24 20:03 duke8253