Table of Contents
This chapter describes error handling and debugging.
Tmax APIs set an error number based on the situation in which an error occurs. Error messages help the user to find the cause of the errors. In order to know the system call level error information, refer to the error messages and APIs defined in tuxinc/Uunix.h.
Tmax provides CLH, which displays information on the console, to help find the problems that occur in the Tmax system, not at the application level.
For more information about error messages that can occur during the operation of the Tmax system, refer to "Tmax Error Message Reference".
The return value of the Tmax API failure differs depending on the API. The error number of each error situation is set in tperrno.
The tpstrerror function, available in both a server and a client, displays a message corresponding to an error number. When an error occurs while using Tmax APIs, a relevant error code will be specified in a tperrno, which is a global variable. A tpstrerror() displays messages about an error specified in a tperrno.
Prototype
# include <atmi.h> char *tpstrerror (int tperrno)
Parameter
Parameter | Description |
---|---|
tperrno | An error code that will display an error message. |
Return Value
Value | Description |
---|---|
Error Message | A message exists for an error code. |
NULL | A message does not exist for an error code. |
Example
#include <stdio.h> #include <usrinc/atmi.h> void main(int argc, char *argv[]) { int ret; char buf; TPSTART_T *tpinfo; tpinfo = (TPSTART_T *)tpalloc(“TPSTART”, NULL, sizeof(TPSTART_T)); if (tpinfo==NULL) { error processing } strcpy(tpinfo->dompwd, “tuxedo”); if (tpstart(tpinfo) == -1){ printf(“tpstart fail , err = %s\n”, tpstrerror(tperrno)); exit(1); } buf = (char *)tpalloc(“CARRAY”, NULL, 20); if (buf==NULL) {error processing }; data process.... tpfree((char *) buf); tpend(); }
Tmax APIs use many system calls. To check a specific system call error generated due an operating system or platform error or to port error messages to heterogeneous platforms, the error messages can be integrated and managed by using the API explained in the following.
The following is the location of the header file.
TMAXDIR/tuxinc/Uunix.h
A variable where an integrated error code is set when an error occurred during a system call.
int Uunixerr
When an ATMI API call fails and a tperrno is set to a TPEOS, a Uunix_err function writes the type of system error to a stderr.
Prototype
# include <Uunix.h> void Uunix_err (char *msg)
Parameter
Parameter | Description |
---|---|
msg | The messages that follow the name of a system call that failed. Generally, a program name is recorded. One of the followings are displayed: UCLOSE, UCREAT, UEXEC, UFCTNL, UFORK, ULSEEK, UMSGCTL, UMSGGET, UMSGSND, UMSGRCV, UOPEN, UPLOCK, UREAD, USEMCTL, USEMGET, USEMOP, USHMCTL, USHMGET, USHMAT, USHMDT, USTAT, UWRITE, USBRK, USYSMUL, UWAIT, UKILL, UTIME, UMKDIR, ULINK, UUNLINK, UUNAME, UNLIST |
Example
ret=tmaxreadenv("NO THAT FILE", "TMAX"); if (ret<0) { Uunix_err("myprog"); exit(1); }
The following is a result of implementing the example above.
mypog: UOPEN
The Ustrerror function returns an integrated error message for a system error code (errno).
Prototype
# include <Uunix.h> char * Ustrerror(int err);
Parameter
Parameter | Description |
---|---|
err | An integrated error number for an error message. |
Return Value
When a system call is succeeded, a pointer to an integrated error message for an errno is returned.
One of the followings is returned in a chr * type pointer:
UCLOSE, UCREAT, UEXEC, UFCTNL, UFORK, ULSEEK, UMSGCTL, UMSGGET, UMSGSND, UMSGRCV, UOPEN, UPLOCK, UREAD, USEMCTL, USEMGET, USEMOP, USHMCTL, USHMGET, USHMAT, USHMDT, USTAT, UWRITE, USBRK, USYSMUL, UWAIT, UKILL, UTIME, UMKDIR, ULINK, UUNLINK, UUNAME, UNLIST
Example
ret=tmaxreadenv("NO THAT FILE", "TMAX"); if (ret<0) { printf("%d->%s\n", Uunixerr, Ustrerror(Uunixerr)); exit(1); }
The following is a result of implementing the example above.
11->UOPEN
If changing clh.dbg, which is located in TMAXDIR/bin, to clh, all the messages handled in CLH can be checked. The original clh file must be backed up.
/home/navis/tmax/bin> tmboot TMBOOT for node(aix5l) is starting: Welcome to Tmax demo system: it will expire 2002/9/15 Today: 2002/7/16 TMBOOT: TMM is starting: Tue Jul 16 22:39:13 2002 TMBOOT: CLL is starting: Tue Jul 16 22:39:13 2002 TMBOOT: CLH is starting: Tue Jul 16 22:39:13 2002 COM: waiting for TMM reply LIB: read 96 bytes (I) CLH Current Tmax Configuration: Number of client handler(MINCLH) = 1 Supported maximum user per node = 3944 Supported maximum user per handler = 3944 LIB: read 96 bytes CLH: bootpid = 31202 TMBOOT: SVR(sub) is starting: Tue Jul 16 22:39:13 2002 TMBOOT: SVR(svr2) is starting: Tue Jul 16 22:39:13 2002 CLH: request_from_server: clh = 0, ind = 0, fd = 8 CLH: msg from server: msgtype = 101, svcname = , len = 0 CLH: register_from_server, spri = 32, svri = 0, maxtms = 32 CLH: reply_to_server: clh = 0, ind = 32, fd =8 CLH: msg to server: msgtype = 1101, svcname = , len = 0 CLH: request_from_server: clh = 0, ind = 0, fd = 9 CLH: msg from server: msgtype = 135, svcname = , len = 0 .....
The libsvrd.a and libsvr.so libraries exist in the TMAXDIR/lib directory. If these libraries are used instead of libsvr.a and libsvr.so, various data values are displayed on the console screen that help the user grasp the flow in the server library and find the point where the error occurred. For libsvrd.so, only the name must be changed. libsvrd.a must be recompiled.
/oracle/navis/tmax385/lib> tmboot TMBOOT for node(tmaxc1) is starting: Welcome to Tmax demo system: it will expire 2002/9/30 ........ GETOPT1: -b 255859 GETOPT1: -s svr2 GETOPT1: -d -1 SVR: delay = -1, _use_lock = 1 COM: waiting for TMM reply LIB: read 96 bytes register_to_tmm success init_shm(78990, 139364) success init_svctab success SVR: my info--1 32 0 0 -3 init_clh success LIB: read 96 bytes register_to_clh success init_txinfo success check_node success _tmax_init = 1 GETOPT1: -b 255859 GETOPT1: -s fdltest GETOPT1: -d -1 SVR: delay = -1, _use_lock = 1 COM: waiting for TMM reply LIB: read 96 bytes register_to_tmm success ......