Copilot commented on code in PR #13410:
URL: https://github.com/apache/trafficserver/pull/13410#discussion_r3617869867


##########
src/iocore/cache/CacheVC.cc:
##########
@@ -210,6 +210,14 @@ CacheVC::do_io_write(Continuation *c, int64_t nbytes, 
IOBufferReader *abuf, bool
   vio.ndone     = 0;
   vio.nbytes    = nbytes;
   vio.vc_server = this;
+  if (nbytes == 0) {
+    // A zero-byte write represents an empty document, while closing without a
+    // write represents a header-only update.
+    f.allow_empty_doc = 1;
+    if (alternate.valid()) {

Review Comment:
   The new `nbytes == 0` handling touches `alternate`/`f.allow_empty_doc` 
before the DEBUG mutex assertion. If a caller ever violates the locking 
contract, this reorders the first access to shared state to occur before the 
diagnostic assert, making failures harder to catch. Consider moving the `#ifdef 
DEBUG ink_assert(!c || c->mutex->thread_holding);` block above the `nbytes == 
0` branch so the lock invariant is checked before accessing `alternate`.



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