3 Replies Latest reply: Jul 8, 2013 3:47 AM by Kristian Ivarsson RSS

    the value returned by tpacall() and tpgetrply()

    652398

        In tuxedo server, I used tpacall() and tpgetrply() to call a service asynchronnously. For example:

      (Note: service will return TPFAIL when calling tpgetrply())

      int hdl = tpacall(serviceName, intpu, intpulen, TPNOTRAN|TPNOBLOCK);

      printf("tpacall: [%d]\n", hdl);

      if (hdl == -1) {

         printf("error");

      } else {

         unsigned long begin = get_time();

         do {

             ret = tpgetrply(&hdl, &output, &outputlen, TPNOBLOCK);

             printf("tpgetrply: [%d]\n", ret);

             if (ret != -1)

                 break;

             usleep(1000*500);

          } while (get_time() - begin < TIME_OUT);

          int lasttime = get_time() - begin;

          if (ret != -1) {

              printf("success");

          } else {

              printf("timeout"):

          }

      }

      it prints:

      tpacall: [64]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      tpgetrply: [-1]

      Warning - HUCREW:TPGETRPLY TIMEOUT,TIMEOUT=10189 ms,TPEBADDESC - bad communication descriptor

       

      My question:

      1. Why tpacall() returns 64 not 0? In my mind, the successful return value of tpcall() is 0 not other values?

      2. tpgetrply() will always return -1 not other values. However, it always return "Timeout" even though it is not timeout error. How to work around it?

       

      Thanks for your kindly reply.

        • 1. Re: the value returned by tpacall() and tpgetrply()
          Per Lindström

          Hi,

           

          1. As you may have several asynchronous calls going on in parallel, tpacall() may return almost any number, depending on how many concurrent asynchronous calls you're making (there is a limit that used to be 50 but I'm not sure what it is in These Modern Times). As the documentation states, -1 indicates an error, other values are potential input to a later call to tpgetrply().

           

          2. I would consider checking that the service you have called is successful and responds in time. Running with the environment variable TMTRACE=on and checking your ULOG afterwards might give you some insights into what's going on further down in the service call stack. You might also consider printing tperrno and tpstrerror(tperrno) after a tpgetrply() failure to find out whether there's a blocking condition (no answer available from the called service yet) or some other error.

           

          Hope this helps,

          /Per

          • 2. Re: the value returned by tpacall() and tpgetrply()
            652398

            Thanks for your kindly reply.

             

            I printed tperrno and tpstrerrno(tperrno) after getrply() as follows. How can I give the correct logic when the service  which is tpacalled returns TPFAIL?

            tpacall: [64]

            tpgetrply: [-1]

            tperrno: [3] tpstrerror(tperrno): [TPEBLOCK - blocking condition found]

            tpgetrply: [-1]

            tperrno: [11] tpstrerror(tperrno): [TPESVCFAIL - application level service failure]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            tpgetrply: [-1]

            tperrno: [2] tpstrerror(tperrno): [TPEBADDESC - bad communication descriptor]

            Warning - SERVICE_A:TPGETRPLY TIMEOUT,TIMEOUT=10196 ms,TPEBADDESC - bad communication descriptor

            • 3. Re: the value returned by tpacall() and tpgetrply()
              Kristian Ivarsson

              Hi 652398,

               

              I believe your client-logic is kind of correct, it is the service that returns with TPFAIL and thus the client finally get the response (with TPESVCFAIL) and that invalidates the descriptor and further attempts to tpgetrply fails with TPEBADDESC

               

              Since you're calling tpgetrply with TPNOBLOCK, the TPEBLOCK-result is "normal" (i.e. no reply has yet arrived)

               

              Your logic should be something like this though

               

              switch( tperrno)

              {

              case TPEBLOCK:
                 /* no reply yet */

                 /* perhaps wait and try again */

                 ...

              case TPESVCFAIL:

                 /* service returned with TPFAIL */

                 /* perhaps report it */

                ...

              default:

                 /* something really bad occured */

                 /* fix the system or the application */

                ...

              }

               

              Best regards,

              Kristian