Changeset 7451 for trunk/tools


Ignore:
Timestamp:
Nov 24, 2001, 9:40:44 PM (24 years ago)
Author:
bird
Message:

Corrected a few bugs. Introduced JobId and multiple daemons.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/CmdQd/CmdQd.c

    r7445 r7451  
    1 /* $Id: CmdQd.c,v 1.10 2001-11-24 06:05:31 bird Exp $
     1/* $Id: CmdQd.c,v 1.11 2001-11-24 20:40:44 bird Exp $
    22 *
    33 * Command Queue Daemon / Client.
     
    291291{
    292292    struct Job *    pNext;              /* Pointer to next job. */
     293    int             iJobId;             /* JobId. */
    293294    int             rc;                 /* Result. */
    294295    PJOBOUTPUT      pJobOutput;         /* Output. */
     
    330331                                        /* since we redirect standard files handles */
    331332                                        /* and changes the currentdirectory. */
     333
     334PSZ         pszSharedMem = SHARED_MEM_NAME; /* Default shared memname */
     335                                        /* Could be overridden by env.var. CMDQD_MEM_NAME. */
    332336
    333337/*******************************************************************************
     
    367371int main(int argc, char **argv)
    368372{
     373    char *  psz;
     374    char    szShrMemName[CCHMAXPATH];
    369375
    370376    /*
     
    380386        }
    381387        return 0;
     388    }
     389
     390    /*
     391     * Check for environment variable which gives us
     392     * the alternate shared mem name.
     393     */
     394    if ((psz = getenv("CMDQD_MEM_NAME")) != NULL)
     395    {
     396        if (strlen(psz) >= CCHMAXPATH - sizeof("\\SHAREMEM\\"))
     397           {
     398           printf("fatal error: CMDQD_MEM_NAME is is too long.\n");
     399           return -1;
     400           }
     401        strcpy(pszSharedMem = &szShrMemName[0], "\\SHAREMEM\\");
     402        strcat(pszSharedMem, psz);
    382403    }
    383404
     
    493514        "    showfailedjobs     - shows jobs which failed.\n"
    494515        "\n"
     516        "   To use multiple daemons for different purposed assing different\n"
     517        "   values to CMDQD_MEM_NAME (env.var.) for the sessions.\n"
     518        "\n"
    495519        "Copyright (c) 2001 knut st. osmundsen (kosmunds@csc.com)\n"
    496520        );
     
    588612                        pJobQueueEnd = pJob;
    589613                    }
    590                     cJobs++;
     614                    pJob->iJobId = cJobs++;
    591615                    DosReleaseMutexSem(hmtxJobQueue);
    592616
     
    804828                             */
    805829                            cch = sprintf(szTmp,
    806                                           "------------------ Job %d\n"
     830                                          "------------------ JobId %d - %d\n"
    807831                                          " command:  %s\n"
    808832                                          " curdir:   %s\n"
    809833                                          " rcIgnore: %d\n",
     834                                          pJob->iJobId,
    810835                                          iJob,
    811836                                          pJob->JobInfo.szCommand,
     
    834859                        *pszOutput = '\0';
    835860                        pShrMem->u1.ShowJobsResponse.fMore = pJob != NULL;
     861                        if (!pJob)
     862                           DosReleaseMutexSem(hmtxJobQueue);
    836863                        rc = shrmemSendDaemon(TRUE);
    837864
     
    913940                             */
    914941                            cch = sprintf(szTmp,
    915                                           "------------------ Failed Job %d\n"
     942                                          "------------------ Failed JobId %d - %d\n"
    916943                                          " command:  %s\n"
    917944                                          " curdir:   %s\n"
    918945                                          " rc:       %d  (rcIgnore=%d)\n",
     946                                          pJob->iJobId,
    919947                                          iJob,
    920948                                          pJob->JobInfo.szCommand,
     
    944972                        *pszOutput = '\0';
    945973                        pShrMem->u1.ShowFailedJobsResponse.fMore = pJob != NULL;
     974                        if (!pJob)
     975                           DosReleaseMutexSem(hmtxJobQueueFine);
    946976                        rc = shrmemSendDaemon(TRUE);
    947977
     
    10231053                             */
    10241054                            cch = sprintf(szTmp,
    1025                                           "------------------ Running Job %d\n"
     1055                                          "------------------ Running JobId %d - %d\n"
    10261056                                          " command:  %s\n"
    10271057                                          " curdir:   %s\n"
    10281058                                          " rcIgnore: %d\n",
     1059                                          pJob->iJobId,
    10291060                                          iJob,
    10301061                                          pJob->JobInfo.szCommand,
     
    10531084                        *pszOutput = '\0';
    10541085                        pShrMem->u1.ShowRunningJobsResponse.fMore = pJob != NULL;
     1086                        if (!pJob)
     1087                           DosReleaseMutexSem(hmtxJobQueue);
    10551088                        rc = shrmemSendDaemon(TRUE);
    10561089
     
    11331166                             */
    11341167                            cch = sprintf(szTmp,
    1135                                           "------------------ Completed Job %d\n"
     1168                                          "------------------ Completed JobId %d - %d\n"
    11361169                                          " command:  %s\n"
    11371170                                          " curdir:   %s\n"
    11381171                                          " rcIgnore: %d\n",
     1172                                          pJob->iJobId,
    11391173                                          iJob,
    11401174                                          pJob->JobInfo.szCommand,
     
    11631197                        *pszOutput = '\0';
    11641198                        pShrMem->u1.ShowCompletedJobsResponse.fMore = pJob != NULL;
     1199                        if (!pJob)
     1200                           DosReleaseMutexSem(hmtxJobQueueFine);
    11651201                        rc = shrmemSendDaemon(TRUE);
    11661202
     
    13921428
    13931429            /* insert into running */
    1394             pJob ->pNext = NULL;
     1430            pJob->pNext = NULL;
    13951431            if (pJobRunningEnd)
    1396                 pJobRunningEnd->pNext = pJob;
     1432                pJobRunningEnd = pJobRunningEnd->pNext = pJob;
    13971433            else
    13981434                pJobRunning = pJobRunningEnd = pJob;
     
    15601596                while (pJobCur)
    15611597                {
    1562                     if (pJobCur->pNext != pJob)
     1598                    if (pJobCur->pNext == pJob)
    15631599                    {
    15641600                        pJobCur->pNext = pJob->pNext;
     
    20002036    APIRET rc;
    20012037    rc = DosGetNamedSharedMem((PPVOID)(PVOID)&pShrMem,
    2002                               SHARED_MEM_NAME,
     2038                              pszSharedMem,
    20032039                              PAG_READ | PAG_WRITE);
    20042040    if (!rc)
     
    22262262    int rc;
    22272263    rc = DosAllocSharedMem((PPVOID)(PVOID)&pShrMem,
    2228                            SHARED_MEM_NAME,
     2264                           pszSharedMem,
    22292265                           SHARED_MEM_SIZE,
    22302266                           PAG_COMMIT | PAG_READ | PAG_WRITE);
     
    23012337     */
    23022338    rc = DosGetNamedSharedMem((PPVOID)(PVOID)&pShrMem,
    2303                               SHARED_MEM_NAME,
     2339                              pszSharedMem,
    23042340                              PAG_READ | PAG_WRITE);
    23052341    if (rc)
Note: See TracChangeset for help on using the changeset viewer.