Writing Handler Functions

    The continuation’s handler function is a function of type . Its arguments are a continuation, an event, and a pointer to some data (this data is passed to the continuation by the caller - do not confuse this data with the continuation’s own data, associated by ). When the continuation is called back, the continuation and an event are passed to the handler function. The continuation is a handle to the same continuation that is invoked. The handler function typically has a switch statement to handle the events it receives:

    Caution

    You might notice that a continuation cannot determine if more events are “in flight” toward it. Do not use TSContDestroy() to delete a continuation before you make sure that all incoming events, such as those sent because of , have been handled.

    Caution

    TS_HTTP_SEND_REQUEST_HDR_HOOK may callback several times when the OS crashed. Be careful to use functions such as TSContDestroy in TS_HTTP_SEND_REQUEST_HDR_HOOK hook.

    The following table lists events and the corresponding type of void* data passed to handler functions:

    The continuation functions are listed below: