Copilot commented on code in PR #12782:
URL: https://github.com/apache/trafficserver/pull/12782#discussion_r2676505893
##########
src/proxy/http/HttpTransact.cc:
##########
@@ -3231,6 +3231,62 @@ HttpTransact::handle_cache_write_lock(State *s)
}
}
+///////////////////////////////////////////////////////////////////////////////
+// Name : handle_deferred_cache_write_complete
+// Description: Called after cache write opens for deferred cache write.
+// We already have the server response headers, so we continue
+// with cache write handling.
+//
+// Possible Next States From Here:
+// - handle_cache_operation_on_forward_server_response (if cache write
succeeded)
+// - handle_no_cache_operation_on_forward_server_response (if cache write
failed)
+//
+///////////////////////////////////////////////////////////////////////////////
+void
+HttpTransact::handle_deferred_cache_write_complete(State *s)
+{
+ TxnDbg(dbg_ctl_http_trans, "handle_deferred_cache_write_complete");
+ TxnDbg(dbg_ctl_http_seq, "Entering handle_deferred_cache_write_complete");
+
+ ink_assert(s->cache_info.action == CacheAction_t::PREPARE_TO_WRITE);
+
+ switch (s->cache_info.write_lock_state) {
+ case CacheWriteLock_t::SUCCESS:
+ // Cache write lock acquired successfully
+ TxnDbg(dbg_ctl_http_trans, "[hdcwc] cache write lock acquired");
+ SET_UNPREPARE_CACHE_ACTION(s->cache_info);
+ // Now we have WRITE action, handle the response with caching
+ handle_cache_operation_on_forward_server_response(s);
+ return;
+
+ case CacheWriteLock_t::FAIL:
+ // Could not get cache write lock, continue without caching
+ TxnDbg(dbg_ctl_http_trans, "[hdcwc] cache write lock failed, continuing
without cache");
+ Metrics::Counter::increment(http_rsb.cache_open_write_fail_count);
+ s->cache_info.action = CacheAction_t::NO_ACTION;
+ s->cache_info.write_status = CacheWriteStatus_t::LOCK_MISS;
+ break;
+
+ case CacheWriteLock_t::READ_RETRY:
+ // This shouldn't happen for deferred write since we don't have an object
to read
+ TxnDbg(dbg_ctl_http_trans, "[hdcwc] unexpected READ_RETRY for deferred
write");
+ s->cache_info.action = CacheAction_t::NO_ACTION;
+ s->cache_info.write_status = CacheWriteStatus_t::LOCK_MISS;
+ break;
+
+ case CacheWriteLock_t::INIT:
+ default:
+ ink_release_assert(0);
+ break;
+ }
+
+ // If we get here, cache write failed - continue without caching
+ // The original handle_no_cache_operation_on_forward_server_response will be
called
+ // but we need to skip the deferred cache write check since we just tried it
+ // s->cache_open_write_deferred is already false from the first call
Review Comment:
This comment is misleading. The flag `cache_open_write_deferred` was set to
false at line 4751 when the cache write was initiated, not "from the first
call". Consider revising to: "s->cache_open_write_deferred was already set to
false before initiating the cache write" for clarity.
```suggestion
// s->cache_open_write_deferred was already set to false before initiating
the cache write
```
--
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]