@@ -55,9 +55,7 @@ HttpCacheAction::cancel(Continuation *c)
5555 ink_assert (this ->cancelled == false );
5656
5757 this ->cancelled = true ;
58- if (_cache_sm->pending_action ) {
59- _cache_sm->pending_action ->cancel ();
60- }
58+ _cache_sm->cancel_pending_action ();
6159}
6260
6361// //
@@ -74,12 +72,16 @@ HttpCacheSM::reset()
7472}
7573
7674void
77- HttpCacheSM::cleanup ()
75+ HttpCacheSM::cancel_pending_action ()
7876{
79- ink_release_assert (this ->mutex && this ->mutex ->thread_holding == this_ethread ());
77+ if (pending_action != nullptr ) {
78+ pending_action->cancel ();
79+ pending_action = nullptr ;
80+ }
8081
8182 if (_read_retry_event != nullptr ) {
8283 _read_retry_event->cancel ();
84+ _read_retry_event = nullptr ;
8385 }
8486}
8587
@@ -329,10 +331,11 @@ HttpCacheSM::do_cache_open_read(const HttpCacheKey &key)
329331 } else {
330332 // In some cases, CacheProcessor::open_read calls back to `state_cache_open_read` with a cache event. If the event is
331333 // CACHE_EVENT_OPEN_READ_FAILED, a read retry event might be scheduled. In this case, CacheProcessor::open_read returns
332- // ACTION_RESULT_DONE, even though the read retry event is still pending. To indicate this situation to HttpSM, the scheduled
333- // read retry event is returned. HttpSM can cancel the event if necessary.
334+ // ACTION_RESULT_DONE, even though the read retry event is still pending. To indicate this situation to HttpSM, `captive_action`
335+ // is returned. HttpSM can cancel the event though this `captive_action` if necessary.
334336 if (_read_retry_event && _read_retry_event->cancelled != true ) {
335- return _read_retry_event;
337+ captive_action.cancelled = false ;
338+ return &captive_action;
336339 } else {
337340 return ACTION_RESULT_DONE;
338341 }
@@ -423,11 +426,12 @@ HttpCacheSM::open_write(const HttpCacheKey *key, URL *url, HTTPHdr *request, Cac
423426 return &captive_action;
424427 } else {
425428 // In some cases, CacheProcessor::open_write calls back to `state_cache_open_write` with a cache event. If the event is
426- // CACHE_EVENT_OPEN_WRITE_FAILED, a read retry event might be scheduled. In this case, CacheProcessor::open_read returns
427- // ACTION_RESULT_DONE, even though the read retry event is still pending. To indicate this situation to HttpSM, the scheduled
428- // read retry event is returned. HttpSM can cancel the event if necessary.
429+ // CACHE_EVENT_OPEN_WRITE_FAILED, a read retry event might be scheduled. In this case, CacheProcessor::open_write returns
430+ // ACTION_RESULT_DONE, even though the read retry event is still pending. To indicate this situation to HttpSM, `captive_action`
431+ // is returned. HttpSM can cancel the event though this `captive_action` if necessary.
429432 if (_read_retry_event && _read_retry_event->cancelled != true ) {
430- return _read_retry_event;
433+ captive_action.cancelled = false ;
434+ return &captive_action;
431435 } else {
432436 return ACTION_RESULT_DONE;
433437 }
0 commit comments