5.5.2 Invalidating Descriptors

If a service calling tpgetrply() (described in detail in Writing Request/Response Clients and Servers) fails with TPETIME and decides to cancel the request, it can invalidate the descriptor with a call to tpcancel(3c). If a reply subsequently arrives, it is silently discarded.

Use the following signature to call the tpcancel() function:

void
tpcancel(int cd)

The cd (call descriptor) argument identifies the process you want to cancel.

tpcancel() cannot be used for transaction replies (that is, for replies to requests made without the TPNOTRAN flag set). Within a transaction, tpabort(3c) does the same job of invalidating the transaction call descriptor.

The following example shows how to invalidate a reply after timing out.

Listing Invalidating a Reply After Timing Out

int cd1;
  .
  .
  .

        if ((cd1=tpacall(sname, (char *)audv, sizeof(struct aud),
           TPNOTRAN)) == -1) {
         .
         .
         .
         }
         if (tpgetrply(cd1, (char **)&audv,&audrl, 0) == -1)
         {
         if (tperrno == TPETIME) {
            tpcancel(cd1);
         .
         .
         .
         }
      }
      tpreturn(TPSUCCESS, 0,NULL, 0L, 0);