Error Handling
This chapter describes error handling and debugging.
1. Overview
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 Message Reference Guide. |
2. API Level Error Processing
The return value of the Tmax API failure differs depending on the API. The error number of each error situation is set in tperrno.
2.1. tpstrerror
The tpstrerror function displays a message corresponding to an error number. It is available on both servers and clients. When an error occurs while using Tmax APIs, the error code is stored in the global variable tperrno. The tpstrerror() function displays a message corresponding to the error code in tperrno.
-
Prototype
# include <atmi.h> char *tpstrerror (int tperrno)
-
Parameter
Parameter Description tperrno
The error code for which the message will be displayed.
-
Return Value
Value Description Error message
A message corresponding to the error code, if available.
NULL
No message is available for the 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(); }
3. System Level Error Processing
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
3.1. Uunixerr
Uunixerr is a variable to set an integrated error code when an error occurs while invoking a system call.
int Uunixerr
3.2. Uunix_err
The Uunix_err function prints a system error message to stderr when an ATMI API call fails and tperrno is set to TPEOS.
-
Prototype
# include <Uunix.h> void Uunix_err (char *msg)
-
Parameter
Parameter Description msg
The message to prepend to the system error message. Typically, this is the program name.
One of the following is printed:
-
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 result is as follows:
mypog: UOPEN
3.3. Ustrerror
The Ustrerror function returns the integrated error message corresponding to a system error code (errno).
-
Prototype
# include <Uunix.h> char * Ustrerror(int err);
-
Parameter
Parameter Description err
The integrated error number for which the error message is to be retrieved.
-
Return Value
If the function call is successful, the pointer address to the integrated error message corresponding to the errno is returned.
One of the following is returned as a char * 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 result is as follows:
11->UOPEN
4. Debug
4.1. Debug CLH
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 ...
4.2. Debug Library
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 ...