Home

Traffic Server Software Developers Kit

INKConfigSet

Assigns an identifier to plugin configuration data.

Prototype

unsigned int INKConfigSet (unsigned int id, void *data, INKConfigDestroyFunc funcp)

Arguments

unsigned int id is the identifier assigned to configuration data. Do not use 1 or 2 for id because Traffic Server internally assigns these IDs to parent and HTTP configurations. You can enter 0 as id, however, and INKConfigSet will allocate an identifier for you (with a value of 3 or greater). There is an internal upper limit of 100 for id.

void *data points to the data that you are associating to id.

INKConfigDestroyFunc funcp is a pointer to a destroy function that's called when Traffic Server determines there are no more references to data. The only argument for funcp is data.

Description

Sets the opaque data pointer data to be associated with the configuration identifier id. If id is 0, then Traffic Server allocates a new configuration identifier, and INKConfigSet returns this value. If id is non-zero, then INKConfigSet returns id. To make sure that the configuration identifier stays within the recommended range of 3 to 100, follow the code example in the previous section.

[Caution] Caution

Never pick a configuration identifier yourself. When you need a new config ID, you must always pass 0 as id to the INKConfigSet API (which will return a new valid id). It is not safe to pick up a randomly-selected id because there might be some conflict with ones already in use by Traffic Server. This can cause severe memory corruption, since the INKConfig mechanism is also used internally by Traffic Server.

The funcp parameter is a pointer to a destroy function that is called with data as its only parameter when Traffic Server determines there are no more references to data.

[Note] Note

Since the current data always has a reference count of at least 1, data will not be destroyed while it is the current piece of configuration data.

See the code snippet in the previous section for usage.

Returns

The unsigned int that was assigned to the data. If the input id is 0, then a new configuration identifier is allocated (with value 3 or larger). If the input id is 0, then the return value is the available identifier allocated by Traffic Server. If id is non-zero, then the return value is id.