Author Topic: RUX function failure - but on multiple tries only...  (Read 9338 times)

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1354
  • Karma: +26/-0
    • View Profile
RUX function failure - but on multiple tries only...
« on: September 29, 2022, 03:00:21 am »
Umm...I'm scratching my head here because I wrote this script a couple of years ago and it has been rock-solid.

The purpose is to check the connectivity between my box and the NAS, which sometimes just flat-out "goes away". Re-starting the NetDrive control fixes it.

Alright, so here is what I call:

Code: [Select]
...
/* check ifthe RXU - RXU.DLL - is required */
   IF rxu_api_required = 1 THEN DO
      /* check if the DLL is already loaded */
      rxu_api = RxFuncQuery('rxuinit')
      msg_text="RXU: already in memory, RC="||rxu_api
      IF rxu_api <> 0 THEN DO
         CALL RxFuncAdd 'rxuinit','RXU','rxuinit'
         CALL rxuinit
         msg_text="RXU: loaded into memory, RC="||rxu_api
         END
      CALL debug debug_flag calling_code msg_level msg_text
     
      /* RXU version API returns a WHOLE bunch of stuff, so parse it first */
      rxu_api_info=rxuquery()
      msg_text=substr(rxu_api_info,pos(',',rxu_api_info,1)+2,pos(',',rxu_api_info,1))
      msg_text="RXU: Using version "||msg_text
      CALL debug debug_flag calling_code msg_level msg_text
      END
...

This normally gives me the following output:

Quote
DEBUG : MAIN => Initializing...
DEBUG :    ==> library_load => Initializing...
DEBUG :    ==> library_load => RXU: loaded into memory, RC=1
DEBUG :    ==> library_load => RXU: Using version v1.a
DEBUG :    ==> library_load => RXUTILEX: loaded into memory, RC=1
DEBUG :    ==> library_load => RXUTILEX: Using version 0.1.6
DEBUG :    ==> library_load => Exiting...
DEBUG : MAIN =>

During the first run I'm all good, no problems.

However, re-runing the 2nd time and aftewards causes this CLI error msg to be produced:

Quote
   282 +++         rxu_api_info = rxuquery();
REX0043: Error 43 running G:\UTIL\MISC\nas_check.cmd, line 282: Routine not
found

...and produces the following matching LOG:

Quote
DEBUG : MAIN => Initializing...
DEBUG :    ==> library_load => Initializing...
DEBUG :    ==> library_load => RXU: already in memory, RC=0
   282 +++         rxu_api_info = rxuquery();
REX0043: Error 43 running G:\UTIL\MISC\nas_check.cmd, line 282: Routine not
found
    76 +++   Call library_load;

The weird part is that this seems to have literally just started on Sep-26th...prior to that I never saw any such failures...ugghhh???

Is there anything obviously wrong that i'm doing here?

BTW - in my code I check to see if I need a particular REXX DLL, if YES, I load it and then un-load it when my script has completed running.

Andi B.

  • Hero Member
  • *****
  • Posts: 870
  • Karma: +14/-2
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #1 on: September 29, 2022, 08:55:19 am »
Quote
I load it and then un-load it when my script has completed running.
I'm not a REXX expert in any way. And what I've to say probably will have anything to do with your problem. But, once I read you should never unload a rexx dll. AFAIR this is because there might be other rexx scripts running which still needs the dll loaded. Maybe my memory is wrong on this, but....

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1354
  • Karma: +26/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #2 on: September 29, 2022, 01:52:05 pm »
Hi Andi,

I'm not a REXX expert in any way. And what I've to say probably will have anything to do with your problem. But, once I read you should never unload a rexx dll. AFAIR this is because there might be other rexx scripts running which still needs the dll loaded. Maybe my memory is wrong on this, but....

You are NOT wrong about that. I had initially implemented this when the DLL load & un-load was still a known problem (OS/2 kernel). Today however this is not the case anymore. Given the situation today I could probably either leave things alone (meaning, just load the required DLL and leave in place), or modify my code to check whether the DLL was already loaded and if found to have been so, leave it alone and not un-load at the end of the script.

The only thing is: I have no idea what changed, just over a couple of days actually...I was experimenting with the JFS cache MIN & MAX buffer sizes, so the last reboot was on the 26th and since then I noticed that my dropped NAS connection reared it's ugly head...LOL!

Lars

  • Hero Member
  • *****
  • Posts: 1367
  • Karma: +70/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #3 on: September 29, 2022, 02:20:10 pm »
As Andy has said: never ever unload a REXX DLL and always just load it when you need it, regardless if it was loaded or not (it is not an error to load a REXX DLL that has already been loaded).

This is NOT a kernel problem (problem of DLL not unloading, bla bla bla). It is a problem of the way the REXX interpreter works internally. It manages the concurrent access to REXX Function DLLs in a way that is unfortunate, to say the least.

Remy

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +12/-1
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #4 on: September 29, 2022, 11:12:45 pm »
Umm...I'm scratching my head here because I wrote this script a couple of years ago and it has been rock-solid.

The purpose is to check the connectivity between my box and the NAS, which sometimes just flat-out "goes away". Re-starting the NetDrive control fixes it.

Alright, so here is what I call:

Code: [Select]
...
/* check ifthe RXU - RXU.DLL - is required */
   IF rxu_api_required = 1 THEN DO
      /* check if the DLL is already loaded */
      rxu_api = RxFuncQuery('rxuinit')
      msg_text="RXU: already in memory, RC="||rxu_api
      IF rxu_api <> 0 THEN DO
         CALL RxFuncAdd 'rxuinit','RXU','rxuinit'
         CALL rxuinit
         msg_text="RXU: loaded into memory, RC="||rxu_api
         END
      CALL debug debug_flag calling_code msg_level msg_text
     
      /* RXU version API returns a WHOLE bunch of stuff, so parse it first */
      rxu_api_info=rxuquery()
      msg_text=substr(rxu_api_info,pos(',',rxu_api_info,1)+2,pos(',',rxu_api_info,1))
      msg_text="RXU: Using version "||msg_text
      CALL debug debug_flag calling_code msg_level msg_text
      END
...

This normally gives me the following output:

Quote
DEBUG : MAIN => Initializing...
DEBUG :    ==> library_load => Initializing...
DEBUG :    ==> library_load => RXU: loaded into memory, RC=1
DEBUG :    ==> library_load => RXU: Using version v1.a
DEBUG :    ==> library_load => RXUTILEX: loaded into memory, RC=1
DEBUG :    ==> library_load => RXUTILEX: Using version 0.1.6
DEBUG :    ==> library_load => Exiting...
DEBUG : MAIN =>

During the first run I'm all good, no problems.

However, re-runing the 2nd time and aftewards causes this CLI error msg to be produced:

Quote
   282 +++         rxu_api_info = rxuquery();
REX0043: Error 43 running G:\UTIL\MISC\nas_check.cmd, line 282: Routine not
found

...and produces the following matching LOG:

Quote
DEBUG : MAIN => Initializing...
DEBUG :    ==> library_load => Initializing...
DEBUG :    ==> library_load => RXU: already in memory, RC=0
   282 +++         rxu_api_info = rxuquery();
REX0043: Error 43 running G:\UTIL\MISC\nas_check.cmd, line 282: Routine not
found
    76 +++   Call library_load;

The weird part is that this seems to have literally just started on Sep-26th...prior to that I never saw any such failures...ugghhh???

Is there anything obviously wrong that i'm doing here?

BTW - in my code I check to see if I need a particular REXX DLL, if YES, I load it and then un-load it when my script has completed running.

If you would like be sure that all RXU functions you are going to call are loaded, you can check each of them at init and if some are missing, load them then instead of just testing 'rxuinit'

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1354
  • Karma: +26/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #5 on: September 30, 2022, 02:20:55 am »
Thanks for all the replies guys!

So a clarification first as I went back through my code to remind myself just what exactly I clubbered together!!!

Well, turns out my initial aim was rather high-enough, meaning:

1) first I check whether I need to use a particular API (that's the rxu_api_required variable)
- this is pre-defined at the start of the REXX script, it's a generic framework I use in all my scripts, so different REXX DLLs may be loaded by different scripts

2) if I need to use a particular REXX DLL API, I then check to see if it's already been loaded into memory (that's the rxu_api variable)

3) at the very end of my code I call the DLL unload procedure where I:
- check to see if all the flagged DLLs have been previously loaded into memory (by examining the rxu_api variable)
- only if one was not previously loaded do I actually un-load it

Sooo...weird, but this was rock-solid, never any problems...then all of a sudden...BAM!!!

I booted to my MAINT partition and did a CHKDSK on my boot drive, found it to be DIRTY, so I ran with a /F parameter. That claimed to correct some things, no messages about lost dirs or files though.

I booted up, re-tested, but still the same failure.

I thought I would re-install the RXU RPM package, but strangely I'm seeing this in ANPM:

Quote
----------[ 29 Sep 2022 20:03:25 ]----------
Executing: @python2.7 G:\UTIL\ANPM\scripts\yum_reinstall.py rxu
Enabling temporary repository arcanoae-sub
Enabling temporary repository arcanoae-exp
Enabling temporary repository arcanoae-stage
Running Transaction Check
Non-fatal POSTIN scriptlet failure in rpm package rxu-1.a.0-3.oc00.pentium4
ERROR: wpi4rpm: Please, close WarpIN and reinstall "rxu" again.


ERROR: wpi4rpm: Please, close WarpIN and reinstall "rxu" again.


warning: %post(rxu-1.a.0-3.oc00.pentium4) scriptlet failed, exit status 253

Return code: 0
----------[ 29 Sep 2022 20:03:40 ]----------

Not sure if the mirror is down or something like that (as I do get a warning from ANPM itself), but I'll re-try later.

For now I have taken the advice to NOT un-load the DLL, so that's been commented out and things appear to work.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1354
  • Karma: +26/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #6 on: September 30, 2022, 02:33:59 am »
Hi Remy,

If you would like be sure that all RXU functions you are going to call are loaded, you can check each of them at init and if some are missing, load them then instead of just testing 'rxuinit'

...so do you mean for example, instead of calling this RXU.DLL entry-point:

Code: [Select]
...
CALL RxFuncAdd 'rxuinit','RXU','rxuinit'
CALL rxuinit
...

call the RxFuncAdd with a specific function from that REXX DLL that I want to use, such as:

Code: [Select]
CALL RxFuncAdd 'RxStartSession','RXU','RxStartSession'
CALL rxuinit

The way I'm loading the DLL is as per the instructions in the DLL INF flie:

Quote
How to register the functions:

In order to use the functions, you have to register them with Rexx like this:

  call rxfuncadd 'rxuinit','rxu','rxuinit'
  call rxuinit
...

For what it's worth, here is the matrix I put together to document the various Load/un-load APIs for specific REXX DLLs:

Code: [Select]
LIBRARY NAME DLL LOAD UNLOAD VERSION API NOTES
=============== =============== =============== =============== =============== ===================================================================

RXU RXU RxuInit RxuTerm RxQuery Version API returns a whole bunch of stuff, need to parse first

REXXUTIL REXXUTIL SysLoadFuncs SysDropFuncs SysUtilVersion

RXUTILEX RXUTILEX Sys2LoadFuncs Sys2DropFuncs Sys2Version

RXEXTRAS RXEXTRAS RxExtra(LOAD) RxExtra(DROP) RxExtra(LOAD)

RXLVM RXLVM RxLvmLoadFuncs RxLvmDropFuncs RxLvmVersion Load and Unload seems to have an issue, fails on repeated attempts
« Last Edit: September 30, 2022, 03:05:27 am by Dariusz Piatkowski »

Lars

  • Hero Member
  • *****
  • Posts: 1367
  • Karma: +70/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #7 on: September 30, 2022, 04:46:44 pm »
One approach is as correct as the other.
Rxinit is just a convenience function that registers all REXX functions. But you can do that function per function by calling rxfuncadd. It is not mandatory to implement an init function but of course, it is convenient for the user.

Remy

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +12/-1
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #8 on: October 04, 2022, 11:49:04 am »
Hi Remy,

If you would like be sure that all RXU functions you are going to call are loaded, you can check each of them at init and if some are missing, load them then instead of just testing 'rxuinit'

...so do you mean for example, instead of calling this RXU.DLL entry-point:

Code: [Select]
...
CALL RxFuncAdd 'rxuinit','RXU','rxuinit'
CALL rxuinit
...

call the RxFuncAdd with a specific function from that REXX DLL that I want to use, such as:

Code: [Select]
CALL RxFuncAdd 'RxStartSession','RXU','RxStartSession'
CALL rxuinit

The way I'm loading the DLL is as per the instructions in the DLL INF flie:

Quote
How to register the functions:

In order to use the functions, you have to register them with Rexx like this:

  call rxfuncadd 'rxuinit','rxu','rxuinit'
  call rxuinit
...

For what it's worth, here is the matrix I put together to document the various Load/un-load APIs for specific REXX DLLs:

Code: [Select]
LIBRARY NAME DLL LOAD UNLOAD VERSION API NOTES
=============== =============== =============== =============== =============== ===================================================================

RXU RXU RxuInit RxuTerm RxQuery Version API returns a whole bunch of stuff, need to parse first

REXXUTIL REXXUTIL SysLoadFuncs SysDropFuncs SysUtilVersion

RXUTILEX RXUTILEX Sys2LoadFuncs Sys2DropFuncs Sys2Version

RXEXTRAS RXEXTRAS RxExtra(LOAD) RxExtra(DROP) RxExtra(LOAD)

RXLVM RXLVM RxLvmLoadFuncs RxLvmDropFuncs RxLvmVersion Load and Unload seems to have an issue, fails on repeated attempts

I would suggest you to check on your needed functions, something like:
e.g.
rxu_api = RxFuncQuery('rxunit')
IF rxu_api <> 0 THEN DO
         CALL RxFuncAdd 'rxuinit','RXU','rxuinit'
         CALL rxuinit
         msg_text="RXU: loaded into memory, RC="||rxu_api
         END
Else do
        rxu_functions = RxFuncQuery('RxStartSession')
        IF rxu_functions <> 0 THEN DO
                   CALL RxFuncAdd 'RxStartSession','RXU','RxStartSession'
                   CALL rxuinit
                   END
        /* Other used functions check routines */
End

Regards

Lars

  • Hero Member
  • *****
  • Posts: 1367
  • Karma: +70/-0
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #9 on: October 04, 2022, 04:15:55 pm »
I think that is not how it is meant to be used. "rxuinit" is a registration-only function and will register all the functions at once. There is no point in checking if each individual function is loaded and call "rxuinit" over and over again.

At least that has been true for all other general load functions (of other REXX DLLs).

So it is either:

rc = rxfuncadd('rxuinit','RXU','rxuinit')
rc = rxuinit()


or:

rc = rxfuncadd('RxStartSession','RXU','RxStartSession')
rc = rxfuncadd('secondFunction,'RXU','secondFunction')
rc = rxfuncadd('thirdFunction','RXU','thirdFunction')
rc = ...

« Last Edit: October 04, 2022, 04:25:09 pm by Lars »

Remy

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +12/-1
    • View Profile
Re: RUX function failure - but on multiple tries only...
« Reply #10 on: October 05, 2022, 01:58:41 pm »
I think that is not how it is meant to be used. "rxuinit" is a registration-only function and will register all the functions at once. There is no point in checking if each individual function is loaded and call "rxuinit" over and over again.

At least that has been true for all other general load functions (of other REXX DLLs).

So it is either:

rc = rxfuncadd('rxuinit','RXU','rxuinit')
rc = rxuinit()


or:

rc = rxfuncadd('RxStartSession','RXU','RxStartSession')
rc = rxfuncadd('secondFunction,'RXU','secondFunction')
rc = rxfuncadd('thirdFunction','RXU','thirdFunction')
rc = ...

This it is.
Fine detailed