PURPOSE

tpscmt - routine for setting when tpcommit() should return

SYNOPSIS

#include <atmi.h>
int tpscmt(long flags)

DESCRIPTION

tpscmt() sets the TP_COMMIT_CONTROL characteristic to the value specified in flags. The TP_COMMIT_CONTROL characteristic affects the way tpcommit(3c) behaves with respect to returning control to its caller. A program can call tpscmt() regardless of whether it is in transaction mode or not. Note that if the caller is participating in a transaction that another program must commit, then its call to tpscmt() does not affect that transaction. Rather, it affects subsequent transactions that the caller will commit.

In most cases, a transaction is committed only when a System/T thread of control calls tpcommit(3c). There is one exception: when a service is dispatched in transaction mode because the AUTOTRAN variable in the *SERVICES section of the UBBCONFIG file is enabled, then the transaction completes upon calling tpreturn(3c). If tpforward(3c) is called, then the transaction will be completed by the server ultimately calling tpreturn(3c). Thus, the setting of the TP_COMMIT_CONTROL characteristic in the service that calls tpreturn(3c) determines when tpcommit(3c) returns control within a server. If tpcommit(3c) returns a heuristic error code, the server will write a message to a log file.

When a client joins a System/T application, the initial setting for this characteristic comes from a configuration file. (See the CMTRET variable in the *RESOURCES section of ubbconfig(5))

Following are the valid settings for flags.

TP_CMT_LOGGED
This flag indicates that tpcommit(3c) should return after the commit decision has been logged by the first phase of the two-phase commit protocol but before the second phase has completed. This setting allows for faster response to the caller of tpcommit(3c) although there is a risk that a transaction participant might decide to heuristically complete (that is, abort) its work due to timing delays waiting for the second phase to complete. If this occurs, there is no way to indicate this situation to the caller since tpcommit(3c) has already returned (although System/T writes a message to a log file when a resource manager takes a heuristic decision). Under normal conditions, participants that promise to commit during the first phase will do so during the second phase. Typically, problems caused by network or site failures are the sources for heuristic decisions being made during the second phase.
TP_CMT_COMPLETE
This flag indicates that tpcommit(3c) should return after the two-phase commit protocol has finished completely. This setting allows for tpcommit(3c) to return an indication that a heuristic decision occurred during the second phase of commit.

RETURN VALUES

Upon success, tpscmt() returns the previous value of the TP_COMMIT_CONTROL characteristic; otherwise it returns -1 on error and sets tperrno to indicate the error condition.

ERRORS

Under the following conditions, tpscmt() fails and sets tperrno to:

[TPEINVAL]
flags is not one of TP_CMT_LOGGED or TP_CMT_COMPLETE.
[TPEPROTO]
tpscmt() was called in an improper context.
[TPESYSTEM]
The exact nature of the error is written to a log file.
[TPEOS]
An operating system error has occurred.

NOTICES

When using tpbegin(3c), tpcommit(3c), and tpabort(3c) to delineate a System/T transaction, it is important to remember that only the work done by a resource manager that meets the XA interface (and is linked to the caller appropriately) has transactional properties. All other operations performed in a transaction are not affected by either tpcommit() or tpabort(). See buildserver(1) for details on linking resource managers that meet the XA interface into a server such that operations performed by that resource manager are part of a System/T transaction.

SEE ALSO

tpabort(3c),
tpbegin(3c),
tpcommit(3c),
tpgetlev(3c)