JosiahWI commented on code in PR #13262:
URL: https://github.com/apache/trafficserver/pull/13262#discussion_r3408284946


##########
include/tscore/DiagsTypes.h:
##########
@@ -45,111 +45,319 @@
 #include "tscore/ink_mutex.h"
 #include "tsutil/Regex.h"
 
+/// Sentinel value stored in Diags::magic to detect heap corruption or
+/// use-after-free of a Diags instance. Diags::magic == DIAGS_MAGIC for
+/// any properly constructed, living instance.
 #define DIAGS_MAGIC 0x12345678
-#define BYTES_IN_MB 1000000
 
-enum DiagsTagType {
-  DiagsTagType_Debug  = 0, // do not renumber --- used as array index
-  DiagsTagType_Action = 1
-};
+/// Bytes-per-megabyte (decimal, not binary). Used by configuration
+/// parsing to convert MB-valued knobs into byte counts.
+#define BYTES_IN_MB 1000000
 
+/**
+ * @brief Selects which of the two tag tables a Diags operation addresses:
+ *   debug tags (controlling Dbg/Diag emission) or action tags (controlling
+ *   is_action_tag_set conditional code paths).
+ *
+ * @note Numeric values are used as array indices into
+ *   DiagsConfigState::_enabled and Diags::activated_tags. Do not renumber.
+ */
+enum DiagsTagType { DiagsTagType_Debug = 0, DiagsTagType_Action = 1 };
+
+/**
+ * @brief Per-DiagsLevel output destination configuration.
+ *
+ * Each boolean controls whether messages at the owning level are emitted
+ * to the corresponding sink. Multiple sinks may be set simultaneously;
+ * the message is emitted to all enabled sinks in unspecified order.
+ *
+ * @thread-safety Carries no internal synchronization. Callers reading or
+ *   modifying Diags::config.outputs[] must respect the concurrency contract
+ *   of the containing DiagsConfigState.
+ */
 struct DiagsModeOutput {
   bool to_stdout;
   bool to_stderr;
   bool to_syslog;
   bool to_diagslog;
 };
 
+/**
+ * @brief Identifies which standard stream Diags::set_std_output reseats.
+ *
+ * STDOUT targets the standard output stream; STDERR targets the standard
+ * error stream.
+ */
 enum StdStream { STDOUT = 0, STDERR };
 
+/**
+ * @brief Selects the rolling policy for a managed log file.
+ *
+ * - NO_ROLLING             — never roll; file grows without bound.
+ * - ROLL_ON_TIME           — roll when the configured time interval elapses.
+ * - ROLL_ON_SIZE           — roll when the configured size threshold is 
exceeded.
+ * - ROLL_ON_TIME_OR_SIZE   — roll when either condition is satisfied.
+ * - INVALID_ROLLING_VALUE  — sentinel; any code path receiving this value MUST
+ *   treat it as NO_ROLLING. MUST be the largest enumerator so that range 
checks
+ *   can detect out-of-range configuration values.
+ */
 enum RollingEnabledValues { NO_ROLLING = 0, ROLL_ON_TIME, ROLL_ON_SIZE, 
ROLL_ON_TIME_OR_SIZE, INVALID_ROLLING_VALUE };
 
+/// Count of valid DiagsLevel values; equal to DL_Undefined and used to
+/// size DiagsConfigState::outputs[].
 #define DiagsLevel_Count DL_Undefined
 
+/// True if the given DiagsLevel causes process termination after emission.
+/// Terminal levels are DL_Fatal and above (excluding DL_Undefined).
 #define DiagsLevel_IsTerminal(_l) (((_l) >= DL_Fatal) && ((_l) < DL_Undefined))
 
-// Cleanup Function Prototype - Called before ink_fatal to
-//   cleanup process state
+/**
+ * @brief Cleanup callback invoked before process termination on a terminal
+ *   DiagsLevel (Fatal, Alert, Emergency).
+ *
+ * @pre The callback runs on the thread that emitted the terminal message.
+ *   It MUST NOT throw. It MUST be async-signal-safe if terminal-level
+ *   emission can occur from a signal handler.
+ * @post On return, the process continues into the exit path for the terminal
+ *   level: DL_Fatal and DL_Alert invoke ink_fatal_va; DL_Emergency invokes
+ *   ink_emergency_va (a distinct, stronger exit path).
+ * @thread-safety Only one callback is installed per Diags instance.
+ *   The callback is invoked at most once per process.
+ */
 using DiagsCleanupFunc = void (*)();
 
+/**
+ * @brief Process-global enable state for the two tag tables.
+ *
+ * Exposes two static methods to read and write the per-tag enable state.
+ * The state for each DiagsTagType is one of:
+ *   0 — disabled (no emission),
+ *   1 — enabled for all callers,
+ *   2 — enabled only when ContFlags::DEBUG_OVERRIDE is set on the
+ *       current Continuation (per-connection debug override).
+ */

Review Comment:
   Not changing. I don't think passing 3 is intended.



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