Coding recommendations for attention events

Attention events are problematic if they arrive while noninterrupt-level handler code is executing. An application may do work it no longer needs to do because the client has cancelled a request.

It is the application’s responsibility to check for attention event periodically if it is performing a time-consuming I/O task or compute-intensive work at the noninterrupt level. The application code should periodically check for attention events using srv_thread_props, with cmd set to CS_GET and property set to SRV_T_GOTATTENTION.

Once it detects an attention event, the Open Server application code can continue to send results, but clients ignore them. The simplest way the application can respond to an attention event is to send a SRV_DONE_FINAL to the client and return.

An attention event can arrive while the Client-Library portion of the gateway application code is executing. The application can call ct_command with the type argument set to CS_CANCEL_ATTN in its SRV_ATTENTION event handler to force the Client-Library routine to return to noninterrupt-level code. Because this command does not take effect unless an attention event arrives, a gateway application should call it routinely.

All gateway calls performing client I/O should check for attention events with srv_thread_props before calling ct_send. This ensures that a query will not be sent to a remote server once the client has already cancelled it.