TSHttpTxnNextHopStrategySet

Synopsis

#include <ts/ts.h>
void TSHttpTxnNextHopStrategySet(TSHttpTxn txnp, TSStrategy strategy)

Description

Sets the next hop strategy for the transaction txnp. This strategy pointer must be a live strategy in the current configuration’s NextHopStrategyFactory, or nullptr to indicate that parent.config will be used instead.

A non-null handle that is not present in the transaction’s strategy factory (e.g. one cached across a configuration reload) is normally rejected: the call is logged and has no effect, leaving the transaction’s strategy unchanged. The check compares addresses, so it is a safety net rather than a guarantee: it never lets the core use a freed strategy, but if a stale handle’s address has been reused by a strategy of the current configuration, that strategy is used. Plugins must re-obtain strategy handles after a configuration reload.

An accepted strategy stays valid for the rest of the transaction, even if remap later selects a different rewrite table (e.g. a virtual host table or one from a configuration reload): the transaction keeps the configuration that owns the strategy alive.

Plugins can get the transaction’s active strategy with TSHttpTxnNextHopStrategyGet(), or look up a strategy by name with TSHttpTxnNextHopStrategyFind(), which uses the transaction’s NextHopStrategyFactory strategy database.

Note

This strategy pointer must not be freed and the contents must not be changed. Strategy pointers held by plugins become invalid when ATS configs are reloaded and must be re-obtained during TSRemapNewInstance()

Deprecated

void TSHttpTxnNextHopStrategySet(TSHttpTxn txnp, void const *strategy)

Deprecated since version 11.0.0: Pass a TSStrategy instead. This 10.2 signature will be removed in a future major release.

Forwards to the TSStrategy overload, so the same check applies. A nullptr argument selects a non-deprecated overload; pass nullptr rather than NULL or 0, which are ambiguous.

See Also

TSHttpTxnNextHopStrategyGet(), TSHttpTxnNextHopStrategyFind().