Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
14.  Handling Errors Returned Integer Status  Previous   Contents   Next 
   
 

Broken Connections

The ToolTalk service provides a function to notify processes if your tool exits unexpectedly. When you include the tt_message_send_on_exit call, the ToolTalk service queues the message internally until one of two events happen:

  1. Your process calls tt_close.

    In this case, the ToolTalk service deletes the message from its queue.

  2. The connection between the ttsession server and your process is broken; for example, the application crashed.

    In this case, the ToolTalk service matches the queued message to a pattern and delivers it in the same manner as if your had sent the message normally before exiting.

Your process can also send a normal message on a normal termination by calling tt_message_send before it calls tt_close. In this case, if your process sends its normal termination message but crashes before it calls tt_close, the ToolTalk service will deliver both the normal termination message and the tt_message_send_on_exit message to interested processes.

Error Propagation

ToolTalk functions that accept pointers always check the pointer passed in and return TT_ERR_POINTER if the pointer is an error value. This check allows you to combine calls in reasonable ways without checking the value of the pointer for every single call.

In Example 14-4, a message is created, filled in, and sent. If tt_message_create fails, an error object is assigned to m, and all the tt_message_xxx_set and tt_message_send calls fail. To detect the error without checking between each call, you only need to check the return code from tt_message_send.


Example 14-4 Error Checking

Tt_message m;

m=tt_message_create();
tt_message_op_set(m,"OP");
tt_message_address_set(m,TT_PROCEDURE);
tt_message_scope_set(m,TT_SESSION);
tt_message_class_set(m,TT_NOTICE);
tt_rc=tt_message_send(m);
if (tt_rc!=TT_OK)...

 
 
 
  Previous   Contents   Next