Home

Traffic Server Software Developers Kit

INKAssert

Enables the use of assertion in a plugin.

Prototype

void INKAssert(expression);

Arguments

A boolean expression.

Description

In debug mode, causes the Traffic Server to print the file name, line number, and expression before it aborts.

In optim mode, the expression is not removed, but the effects of printing an error message and aborting are. This is an artifact of the way the system assert is normally used and permits:

ink_assert(!setsockopt(...)); 

Note: when using the system “assert”, you do not need to worry about the condition since the code will be 'dead code eliminated' by the compiler; with INKAssert, you do.

Example
switch (event) {
case EVENT_IMMEDIATE:
....
default:
INKAssert (!setsockopt(...));
break;
}