masaori335 commented on code in PR #12601:
URL: https://github.com/apache/trafficserver/pull/12601#discussion_r2453602137


##########
src/iocore/cache/Cache.cc:
##########
@@ -342,7 +342,9 @@ Cache::open_read(Continuation *cont, const CacheKey *key, 
CacheFragType type, st
   CacheVC      *c     = nullptr;
   {
     CACHE_TRY_LOCK(lock, stripe->mutex, mutex->thread_holding);
-    if (!lock.is_locked() || (od = stripe->open_read(key)) || 
stripe->directory.probe(key, stripe, &result, &last_collision)) {
+    CACHE_DIR_TRY_LOCK_SHARED(dir_lock, stripe->dir_mutex);
+    if (!lock.is_locked() || !dir_lock.is_locked() || (od = 
stripe->open_read(key)) ||
+        stripe->directory.probe(key, stripe, &result, &last_collision)) {

Review Comment:
   Having `mutex` and `dir_mutex` might be good approach. When we call 
`Directory::probe` with read lock of `dir_mutex`, but it needs write operation 
(it's rare case I assume), we can wait for `mutex` lock. Obviously, we have to 
be careful for dead lock.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to