IBM / db2sock-ibmi

An asynchronous PASE Db2 and IBM i integration library
MIT License
4 stars 7 forks source link

Changing job description #13

Closed kadler closed 6 years ago

kadler commented 6 years ago

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Is there any way you could select what job description is used when calling a program through db2sock?

I've also been toying around with _PGMCALL for faster program call. If there is a way to specify a job description for that it would be a great help.

I call _PGMCALL like this

In PaseTool.c tool_key_pgm_call_run()

  void *pgm_args[ILE_PGM_MAX_ARGS+1];
  int argc, offset, parmc;
  for (argc=0; argc < ILE_PGM_MAX_ARGS; argc++) {
    if (argc < layout->argc) {
      if (layout->argv_parm[argc] > -1) {
        parmc = layout->argv_parm[argc];
        offset = layout->arg_pos[parmc];
        pgm_args[argc] = (void *)layout + offset;
      }
    } else {
      pgm_args[argc] = NULL;
    }
  }
  char *libl = "*LIBL";
  if(tpgm->pgm_ile_lib){
    libl = tpgm->pgm_ile_lib;
  }

  ILEpointer pgm_pointer;
  int rc = _RSLOBJ2(&pgm_pointer,
                 RSLOBJ_TS_PGM,
                 tpgm->pgm_ile_name,
                 libl);

  rc = _PGMCALL(&pgm_pointer,
                (void*)&pgm_args,
                0);
kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


You have a very old fork of this project (relative to code base). No commit activity from 2017-10-17 (forever). Can you delete?

I updated my fork, that is mostly the code I'm currently using. I've had to make some minor tweaks to get certain things to work.

Job description problems seems to be fixed at least for now by changing the PHP user and job. Fork400 wasn't doing what I though so that is abandoned.

I need to take your points about the PGMCALL into consideration, but you still haven't convinced me out of it :smile:.

This issues was heavily derailed, so I'll close this. Later I might open a new one about the PGMCALL.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Changing job description

We already answered this question.

You may always 'choose' a job description for any user profile (chgusrprf). You also have access to any system APIs through the toolkit, so altering state of a process is essentially the same as and running RPG program. Of course, like RPG, you are bound by the same rules with toolkit running in a process.

Everything else followed was attempt help you understand many issues far beyond "change job description". I have clearly laid out my cards for async in php, etc.

I am still not sure we should add a PGMCALL/ILECALL path. Maybe open another issue for that topic specifically if you want to see this added to db2sock (assuming you are even using this project db2sock).

Are we done this issue?

kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


However, warning, next step , SRVPGM call via _ILECALL is beyond abilities of most everyone (beyond IBM lab). I suspect you will NOT be able to code this correctly (just trying to be helpful). All-in-all i suspect you need help to pull this off.

Oh yes, that argument list on _ILECALL looks scary. But I haven't yet come across any SRVPGMs on our system so maybe I won't have to touch that.

Again, I am asking, do you really think in memory call is worth all the problems (like python iLibCall)?? I am not completely against adding to db2sock, but i have trouble justifying this work with so many production situations it will fail (relative train wreck).

On one machine _PGMCALL almost doubles the performance so it seems really good. Still we have no idea why there isn't a performance gain on the other machine.

kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Yes, there seems to be all kinds of problems with _PGMCALL. Like all programs don't even give output and I seem to be unable to get errors through QMHRCVPM... fortunately %parms seem to be working. Also it only gives speed boost on our 7.1 machine and not in newer 7.3 so there is definitely something weird going around.

Currently I only have to care about PHP so I try to avoid async stuff. I also have no idea about these QTEMP issues as I don't understand who, how and why uses that.

But back to the job description, I found this fork400() function (https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/apis/pase_fork400.htm) which could be used to set job description. One solution might be to start PHP with certain JOB/USER, but that hasn't been tested yet. My initial testing with fork400 seems to give good results but it needs more thinking and pondering...

If this PGMCALL seem to be a horrible train wreck is there a way to choose job description when using the current stored procedure way?

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


I've also been toying around with _PGMCALL for faster program call. If there is a way to specify a job description for that it would be a great help.

Short answer ... no.

Longer answer ... _PGMCALL and _ILECALL are in-line or in-memory calls in current process. Thereby, running as current profile. However, like any process, you may toolkit call cmds and/or system APIs to change conditions of the process (same as RPG).