Esc

release_tls_config

procedureextensionexperimentalsince 0.36.1Source
  • macOS: release_tls_config works on macOS
  • Linux: release_tls_config works on Linux
  • Windows: release_tls_config works on Windows
  • Wasm: release_tls_config works on Wasm

Frees a client TLS config that connections were made with. It closes every pooled connection of the running scheduler that uses the config (HTTP/1.1 and HTTP/2, and the h2-less copy that client_settings.http2 = false makes of it), forgets what the pool knew about the config, then releases it like Tls.tls_config_free. Use this instead of Tls.tls_config_free for a config that was a client.tls: a pooled connection closes through its config, and a config allocated at the same address later would otherwise be given connections that were made with the old one.

Signature

release_tls_config :: (config: *Tls.Tls_Config)

Responses made with the config must be read to the end or closed first, and no request using it may be in flight. Call it on the scheduler that made the requests: pools are per scheduler.

Example
Tls :: #import "Extensions/Tls";

config: Tls.Tls_Config;
config.alpn = .["h2", "http/1.1"];
assert(Tls.tls_config_init(*config).kind == .NONE);

api: Client;
api.tls = *config;

// ... requests with `api`, every response read or closed ...

release_tls_config(*config);
assert(config.native == null);

See also