1 Reply Latest reply: Dec 15, 2011 2:17 PM by Ed Heeren-Oracle RSS

    Help! Multicontexted tpint in native client

    MichaelT
      Hi, I'm trying to write a native client that will join multiple Tux applications. I am calling tpinit() with the TPMULTICONTEXTS flag as follows:

      TPINIT* tpinfo = NULL;
      if ((tpinfo = (TPINIT *)tpalloc("TPINIT", NULL, TPINITNEED(0))) == NULL)
      {
      cerr<<tpstrerror(tperrno)<<endl;
      return;
      }

      std::strcpy(tpinfo->usrname, "mibcl");
      std::strcpy(tpinfo->passwd, "0x80000000");
      std::strcpy(tpinfo->cltname, "tpsysadm");
      tpinfo->flags = TPMULTICONTEXTS;

      if (tpinit(tpinfo) == -1)
      {
      cerr<<tpstrerror(tperrno)<<endl;
      tpfree((char*)tpinfo);
      return;
      }

      TPCONTEXT_T ctxt;
      int res = tpgetctxt(&ctxt, 0);
      // TODO - debug
      switch(res)
      {
      case TPSINGLECONTEXT:
      cout<<"Context: TPSINGLECONTEXT"<<endl;
      break;
      case TPNULLCONTEXT:
      cout<<"Context: TPNULLCONTEXT"<<endl;
      break;
      case TPINVALIDCONTEXT:
      cout<<"Context: TPINVALIDCONTEXT"<<endl;
      break;
      default:
      cout<<"Context: "<<res<<endl;
      }
      // end debug
      tpfree((char*)tpinfo);


      But despite the TPMULTICONTEXTS flag tpgetctxt(...) always returns TPSINGLECONTEXT. Am I doing something wrong?


      Oracle Tuxedo, Version 11.1.1.2.0 with VS2010, 64-bit, Patch Level (none)
      Microsoft Windows Server 2008 R2 Enterprise 6.1.7601 Service Pack 1 Build 7601
        • 1. Re: Help! Multicontexted tpint in native client
          Ed Heeren-Oracle
          Michael,

          tpgetctxt() returns -1 on error and returns a different value (which happens to always be 0) on success. When tpgetctxt() succeeds, ctxt is set to the current context, which may be TPSINGLECONTEXT, TPNULLCONTEXT, TPINVALIDCONTEXT, or the context number of the current multicontext mode context.

          You should check if (res == -1) after calling tpgetctxt(). If (res != -1) you should switch(ctxt) instead of switch(res).

          Regards,

          Ed