11.23 Communication Etiquette
When writing code to be run in transaction mode, you must observe the following rules of basic communication etiquette:
- Processes that are participants in the same transaction must require replies for all requests. To include a request that requires no reply, set the
flagsparameter oftpacall()toTPNOTRANorTPNOREPLY. - A service must retrieve all asynchronous transaction replies before calling
tpreturn()ortpforward(). This rule must be observed regardless of whether the code is running in transaction mode. - The initiator must retrieve all asynchronous transaction replies (made without the
TPNOTRANflag) before callingtpcommit(). - Replies must be retrieved for asynchronous calls that expect replies from non-participants of the transaction, that is, replies to requests made with
tpacall()in which the transaction, but not the reply, is suppressed. - If a transaction has not timed out but is marked
“abort-only,” any further communication must be
performed with the
TPNOTRANflag set so that the results of the communication are preserved after the transaction is rolled back. - If a transaction has timed out:
- The descriptor for the timed-out call becomes stale and any further reference to it returns
TPEBADDESC. - Further calls to
tpgetrply()ortprecv()for any outstanding descriptors return a global state of transaction timeout; the system setstperrno(5)toTPETIME. - Asynchronous calls can be made with the
flagsparameter oftpacall()set toTPNOREPLY,TPNOBLOCK, orTPNOTRAN.
- The descriptor for the timed-out call becomes stale and any further reference to it returns
- Once a transaction has been marked “abort-only” for reasons other than timeout, a call to
tpgetrply()returns whatever value represents the local state of the call; that is, it returns either success or an error code that reflects the local condition. - Once a descriptor is used with
tpgetrply()to retrieve a reply, or withtpsend()ortprecv()to report an error condition, it becomes invalid and any further reference to it returnsTPEBADDESC. This rule is always observed, regardless of whether the code is running in transaction mode. - Once a transaction is aborted, all outstanding transaction call
descriptors (made without the
TPNOTRANflag) become stale, and any further references to them returnTPEBADDESC.
Parent topic: Managing Errors