Changeset 30


Ignore:
Timestamp:
Jan 26, 2016, 4:27:09 PM (10 years ago)
Author:
Alex Taylor
Message:

Applied updates (from SHL) to improve stability of process listing.

Location:
rxutilex/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rxutilex/trunk/rxutilex.c

    r29 r30  
    8484#define SZ_LIBRARY_NAME         "RXUTILEX"  // Name of this library
    8585#define SZ_ERROR_NAME           "SYS2ERR"   // REXX variable used to store error codes
    86 #define SZ_VERSION              "0.1.2"     // Current version of this library
     86#define SZ_VERSION              "0.1.3"     // Current version of this library
    8787
    8888// Maximum string lengths...
     
    108108// Drop list starts at index 0, load list starts at index 1
    109109static PSZ RxFunctionTbl[] = {
    110     "Sys2LoadFuncs",                    // Drop only 2015-05-06 sSHL
     110    "Sys2LoadFuncs",                    // Drop only 2015-05-06 SHL
    111111    "Sys2DropFuncs",
    112112    "Sys2GetClipboardText",
     
    652652ULONG Sys2QueryProcessList( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult )
    653653{
    654 #ifdef USE_DQPS
    655     QSPTRREC *pBuf;                     // Data returned by DosQProcStatus()
    656 #else
    657     QSPTRREC *pBuf;                      // Data returned by DosQuerySysState() // 2015-04-23 SHL
    658 #endif
     654    QSPTRREC *pBuf;                      // Data returned by DosQProcStatus/DosQuerySysState() // 2015-04-23 SHL
    659655    QSPREC *pPrec;                      // Pointer to process information block
    660656    QSTREC *pTrec;                      // Pointer to thread information block
     
    697693
    698694#ifdef USE_DQPS
    699     // Get running process information using DosQProcStatus()
     695    // Get running process information using 16-bit DosQProcStatus()
    700696    rc = DosQProcStatus( pBuf, UL_SSBUFSIZE );
    701697    if ( rc != NO_ERROR ) {
     
    704700        return ( 0 );
    705701    }
    706     pPrec = pBuf->pProcRec;             // 2015-04-23 SHL
    707702#else
    708     // Get running process information using DosQuerySysState()
     703    // Get running process information using 32-bit DosQuerySysState()
    709704    rc = DosQuerySysState( QS_PROCESS, 0L, 0L, 0L, pBuf, UL_SSBUFSIZE );
    710705    if ( rc != NO_ERROR ) {
     
    713708        return ( 0 );
    714709    }
    715     pPrec = pBuf->pProcRec;
    716710#endif
    717711
    718712    // Now get the list of processes
    719713    ulCount = 0;
    720     while ( pPrec->RecType == 1 ) {
     714#   if 1 // 2015-06-12 SHL FIXME to know if can occur
     715    if ( pBuf->pProcRec == NULL ) {
     716        WriteErrorCode( rc, "pBuf->pProcRec NULL");
     717        MAKERXSTRING( *prsResult, "", 0 );
     718        return ( 0 );
     719    }
     720#   endif
     721
     722    // 2015-06-12 SHL pThrdRec can be 0 - probably when process starting or dieing
     723    for (pPrec = pBuf->pProcRec;
     724         ;
     725         pPrec = pPrec->pThrdRec ?
     726                   (QSPREC *)(pPrec->pThrdRec + pPrec->cTCB) :
     727                   pPrec + 1
     728        )
     729
     730    {
     731#       if 1
     732        // 2015-06-19 SHL FIXME to be gone if proven that never can occur
     733        if ((ULONG)pPrec < 0x10000) {
     734            fprintf(stderr, "* rxutilex#%u ulCount %u pPrec %p\n", __LINE__, ulCount, pPrec);
     735            break;                      // Avoid death
     736        }
     737#       endif
     738
     739        // 2015-06-19 SHL FIXME debug was trapping here if pThrdRec NULL
     740        if (pPrec->RecType != QS_PROCESS)
     741            break;
     742
     743#       if 1
     744        /* Avoid death if no threads
     745           This is undocumented but probably occurs if called while process
     746           is starting or terminating
     747           2015-07-31 SHL
     748        */
     749        if (!pPrec->cTCB)
     750          fprintf(stderr, "* rxutilex#%u ulCount %u pBuf %p pPrec %p pPrec->pThrdRec %p pPrec->cTCB %u\n", __LINE__, ulCount, pBuf, pPrec, pPrec->pThrdRec, pPrec->cTCB);
     751        // 2015-07-31 SHL FIXME debug
     752        if ((ULONG)(pPrec->pThrdRec) < 0x10000) {
     753          fprintf(stderr, "* rxutilex#%u ulCount %u pBuf %p pPrec %p pPrec->pThrdRec %p pPrec->cTCB %u\n", __LINE__, ulCount, pBuf, pPrec, pPrec->pThrdRec, pPrec->cTCB);
     754          break;                        // Avoid death
     755        }
     756#       endif
     757
    721758        ulCount++;
    722759
     
    747784        WriteStemElement( szStem, ulCount, szPInfo );
    748785
    749         pPrec = (QSPREC *) ( (PBYTE) (pPrec->pThrdRec) + ( pPrec->cTCB * sizeof(QSTREC) ) );
    750     }
     786#       if 1    // 2015-07-31 SHL FIXME debug
     787        // 2015-07-31 SHL FIXME debug
     788        if (!pPrec->cTCB) {
     789          fprintf(stderr, "* rxutilex: szPInfo %s\n", szPInfo);
     790          fprintf(stderr, "* rxutilex: ulCount %u pBuf %p pPrec %p pPrec->pThrdRec %p pPrec->cTCB %u\n", ulCount, pBuf, pPrec, pPrec->pThrdRec, pPrec->cTCB);
     791          fprintf(stderr, "* rxutilex: next RecType %x\n", (pPrec + 1)->RecType);
     792    }
     793        // 2015-07-31 SHL FIXME debug
     794        if ((ULONG)pPrec->pThrdRec < 0x10000 || !pPrec->cTCB) {
     795          fprintf(stderr, "* rxutilex: szPInfo %s\n", szPInfo);
     796          fprintf(stderr, "* rxutilex: ulCount %u pBuf %p pPrec %p pPrec->pThrdRec %p pPrec->cTCB %u\n", ulCount, pBuf, pPrec, pPrec->pThrdRec, pPrec->cTCB);
     797          fprintf(stderr, "* rxutilex: next RecType %x\n", (pPrec + 1)->RecType);
     798          break;                // Avoid death
     799        }
     800#       endif
     801    } // for
    751802
    752803    // Create the "0" stem element with the number of processes found
  • rxutilex/trunk/rxutilex.def

    r29 r30  
    11LIBRARY     RXUTILEX INITINSTANCE TERMINSTANCE
    22DATA        MULTIPLE NONSHARED
    3 DESCRIPTION '@#Alex Taylor:0.1.2#@##1## 27 Jan 2016 00:11:55     REINFORCE::::::@@Extended REXX Utility Functions'
     3DESCRIPTION '@#Alex Taylor:0.1.3#@##1## 27 Jan 2016 00:26:24     REINFORCE::::::@@Extended REXX Utility Functions'
    44
    55EXPORTS     Sys2LoadFuncs
Note: See TracChangeset for help on using the changeset viewer.