Dynamic Probe Class Library

Dynamic Probe Class Library Programming Guide


Chapter 16. Overriding default system callbacks

As described in What are DPCL callbacks?, most DPCL callbacks are initiated by analysis tool requests. Acknowledgment callbacks, for example, respond to the success/failure of an asynchronous function. These success/failure messages are sent from one or more DPCL communication daemons running on one or more hosts. Similarly, data callbacks respond to message data sent by the DPCL communication daemon(s) -- either messages forwarded from installed probes, or diagnostic messages. In all of these cases, however, the messages sent from the DPCL communication daemon to the analysis tool are the result of a direct request from the analysis tool -- either an asynchronous request, a request to install a probe, or a request to turn diagnostic logging on. Furthermore, in all these cases, the analysis tool code will have specified, upon making the request, the name of a callback routine to handle the messages from the DPCL communication daemon(s).

System callbacks, on the other hand, are different than these user-initiated requests. They are not the result of a request from the analysis tool, but are instead used to respond to unexpected events (possibly due to system error) such as the DPCL communication daemon exiting. The default system callbacks respond to these unexpected events simply by printing an error or information message describing the event. However, if you would like your analysis tool to respond to any of these events in another way, you can use the Ais_override_default_callback function to override the default system callback and call your own callback instead.

To override a default system callback using the Ais_override_default_callback function, you supply a message key that indicates the type of system message you want to handle in your callback routine. The message types are:

AIS_DEFAULT_MSG
If you specify this message type when calling the Ais_override_default_callback function, your callback will be invoked when the DPCL communication daemon receives a message that otherwise has no associated callback routine. This callback will be invoked only in cases of an internal DPCL error.

AIS_EXIT_MSG
If you specify this message type when calling the Ais_override_default_callback function, your callback will be invoked when a DPCL communication daemon unexpectedly exits. The message that activates this callback contains the socket handle for the connection to the daemon that exited.

AIS_PROC_TERMINATE_MSG
If you specify this message type when calling the Ais_override_default_callback function, your callback will be invoked when a target application process terminates. The message is an integer containing the process ID of the process that terminated. The host on which the terminated process was running can be inferred by examining the msg_socket field of the GCBSysType parameter passed to your function and then matching up the socket and Process values.

The following example code overrides the default system callback for handling termination of the DPCL daemon. In this example, the new callback is my_exit_cb.

Ais_override_default_callback(AIS_EXIT_MSG, my_exit_cb, (GCBTagType) 0,

             &prev_cb, &prev_tag);

 

For more information about the Ais_override_default_callback function, refer to its UNIX man page or its entry in the DPCL Class Reference.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]