This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d73f1cdff Fix: msdms log fields emit dash instead of -1 for unset 
milestones (#12900)
3d73f1cdff is described below

commit 3d73f1cdff0de84d4022603611351e7d6c4add2d
Author: Bryan Call <[email protected]>
AuthorDate: Sat Feb 21 10:12:30 2026 -0800

    Fix: msdms log fields emit dash instead of -1 for unset milestones (#12900)
    
    * Add unmarshal_milestone_diff() which outputs "-" instead of "-1"
      when a milestone difference equals the -1 sentinel (milestone
      unset). Log parsers can now distinguish "0 ms" (valid timing) from
      "not applicable" without magic integer checks.
    
    * Wire MSDMS container to the new unmarshal function in LogField.cc
      instead of the generic unmarshal_int_to_str.
    
    * Only map the -1 sentinel to dash, not all negatives -- preserves
      debug info from reversed milestone pairs (end < start).
---
 include/proxy/logging/LogAccess.h |  1 +
 src/proxy/logging/LogAccess.cc    | 37 +++++++++++++++++++++++++++++++++++++
 src/proxy/logging/LogField.cc     |  2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/include/proxy/logging/LogAccess.h 
b/include/proxy/logging/LogAccess.h
index cfe3bf557f..c50bb359c5 100644
--- a/include/proxy/logging/LogAccess.h
+++ b/include/proxy/logging/LogAccess.h
@@ -318,6 +318,7 @@ public:
   static int     unmarshal_itox(int64_t val, char *dest, int field_width = 0, 
char leading_char = ' ');
   static int     unmarshal_int_to_str(char **buf, char *dest, int len);
   static int     unmarshal_int_to_str_hex(char **buf, char *dest, int len);
+  static int     unmarshal_milestone_diff(char **buf, char *dest, int len);
   static int     unmarshal_str(char **buf, char *dest, int len, LogSlice 
*slice, LogEscapeType escape_type);
   static int     unmarshal_ttmsf(char **buf, char *dest, int len);
   static int     unmarshal_int_to_date_str(char **buf, char *dest, int len);
diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc
index d04082fdce..336238c345 100644
--- a/src/proxy/logging/LogAccess.cc
+++ b/src/proxy/logging/LogAccess.cc
@@ -627,6 +627,43 @@ LogAccess::unmarshal_int_to_str(char **buf, char *dest, 
int len)
   return -1;
 }
 
+/*-------------------------------------------------------------------------
+  LogAccess::unmarshal_milestone_diff
+
+  Unmarshal a milestone difference value.  Returns "-" when the
+  marshalled value is -1 (the "missing" sentinel from difference_msec,
+  meaning one or both milestones were unset).  Other negative values
+  (reversed milestone order) are preserved as numeric output for
+  debugging.
+  -------------------------------------------------------------------------*/
+
+int
+LogAccess::unmarshal_milestone_diff(char **buf, char *dest, int len)
+{
+  ink_assert(buf != nullptr);
+  ink_assert(*buf != nullptr);
+  ink_assert(dest != nullptr);
+
+  int64_t val = unmarshal_int(buf);
+  if (val == -1) {
+    if (len >= 1) {
+      dest[0] = '-';
+      return 1;
+    }
+    DBG_UNMARSHAL_DEST_OVERRUN
+    return -1;
+  }
+
+  char val_buf[128];
+  int  val_len = unmarshal_itoa(val, val_buf + 127);
+  if (val_len < len) {
+    memcpy(dest, val_buf + 128 - val_len, val_len);
+    return val_len;
+  }
+  DBG_UNMARSHAL_DEST_OVERRUN
+  return -1;
+}
+
 /*-------------------------------------------------------------------------
   LogAccess::unmarshal_int_to_str_hex
 
diff --git a/src/proxy/logging/LogField.cc b/src/proxy/logging/LogField.cc
index f7dcbbd067..039aca32a7 100644
--- a/src/proxy/logging/LogField.cc
+++ b/src/proxy/logging/LogField.cc
@@ -388,7 +388,7 @@ LogField::LogField(const char *field, Container container)
     if (0 != rv) {
       Note("Invalid milestone range in LogField ctor: %s", m_name);
     }
-    m_unmarshal_func = &(LogAccess::unmarshal_int_to_str);
+    m_unmarshal_func = &(LogAccess::unmarshal_milestone_diff);
     m_type           = LogField::sINT;
     break;
   }

Reply via email to