shukitchan commented on code in PR #12645:
URL: https://github.com/apache/trafficserver/pull/12645#discussion_r2505647477


##########
plugins/header_rewrite/operators.cc:
##########
@@ -1800,3 +1800,45 @@ OperatorIf::exec_section(const CondOpSection *section, 
const Resources &res) con
 
   return section->ops.oper_mods;
 }
+
+// OperatorSetCongestionCtrl
+void
+OperatorSetCCAlgorithm::initialize(Parser &p)
+{
+  Operator::initialize(p);
+  _cc_alg.set_value(p.get_arg());
+}
+
+void
+OperatorSetCCAlgorithm::initialize_hooks()
+{
+  add_allowed_hook(TS_REMAP_PSEUDO_HOOK);
+  add_allowed_hook(TS_HTTP_SEND_REQUEST_HDR_HOOK);
+  add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
+  add_allowed_hook(TS_HTTP_PRE_REMAP_HOOK);
+}
+
+bool
+OperatorSetCCAlgorithm::exec(const Resources &res) const
+{
+  Dbg(dbg_ctl, "OperatorSetCCAlgorithm");
+
+  if (!res.state.txnp) {
+    TSError("[%s] OperatorSetCCAlgorithm() failed. Transaction is null", 
PLUGIN_NAME);
+    return false;
+  }
+
+  int client_fd;
+  if (TSHttpTxnClientFdGet(res.state.txnp, &client_fd) != TS_SUCCESS) {
+    TSError("[%s] [OperatorSetCCAlgorithm] Error getting client fd", 
PLUGIN_NAME);
+  }
+
+#ifdef TCP_CONGESTION
+  if (safe_setsockopt(client_fd, IPPROTO_TCP, TCP_CONGESTION, 
_cc_alg.get_value().data(), _cc_alg.size()) == -1) {
+    TSError("[%s] [OperatorSetCCAlgorithm] Error setting congestion control 
algorithm, errno=%d %s", PLUGIN_NAME, errno,
+            strerror(errno));
+  }
+
+#endif

Review Comment:
   Perhaps we should output an error or warning saying that it is not supported 
in the current system if TCP_CONGESTION is not defined?



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