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 you 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 about 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 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

Available in both a server and a client. This function 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)
  • Parameters

    Parameter Description

    tperrno

    An error code that will display an error message.

  • Return Values

    Value Description

    Error Message

    A message exists for an error code.

    NULL

    A message does not exist for an error code.

  • Examples

    #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

Variable that is set to an integrated error number if a system call error occurs.

int Uunixerr

3.2. Uunix_err

Writes the type of system error to a stderr when an ATMI API call fails and a tperrno is set to a TPEOS.

  • Prototype

    # include <Uunix.h>
    void Uunix_err (char *msg)
  • Parameters

    Parameter Description

    msg

    The messages that follow the name of a system call that failed. Generally, a program name is recorded.

    One of the following is 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

  • Examples

    ret=tmaxreadenv("NO THAT FILE", "TMAX");
    if (ret<0) {
       Uunix_err("myprog");
       exit(1);
    }

    The following is the result of executing the previous example.

    mypog: UOPEN

3.3. Ustrerror

Returns an integrated error message for a system error code (errno).

  • Prototype

    # include <Uunix.h>
    char * Ustrerror(int err);
  • Parameters

    Parameter Description

    err

    An integrated error number for an error message.

  • Return Values

    When a system call is succeeded, a pointer to an integrated error message for an errno is returned.

    One of the following is returned through a chr * 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

  • Examples

    ret=tmaxreadenv("NO THAT FILE", "TMAX");
    if (ret<0)
    {
        printf("%d->%s\n", Uunixerr, Ustrerror(Uunixerr));
        exit(1);
    }

    The following is the result of executing the previous example.

    11->UOPEN

3.4. tmaxoserrno

Variable that is set to an integrated error number if a system call error occurs. The error number can be changed if another error occurs, which makes difficult to find a reason. tmaxoserrno has a system error number at the point in time when TPEOS or TPESYSTEM occurs. Windows saves GetLastError() values and Unix saves errno values.

# include <atmi.h>
int tmaxoserrno;

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
........