IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 11, 2006, 4:51:50 PM (20 years ago)
Author:
eugene
Message:

working on threaded version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c

    r7917 r8296  
    11# include "pcontrol.h"
    22
     3/* the supplied host is not on a stack: it cannot be taken by the other thread */
    34int CheckIdleHost (Host *host) {
    45
     
    78  Job *job;
    89
     10  /* search the JOB_PENDING stack for an appropriate job */
    911  stack = GetJobStack (PCONTROL_JOB_PENDING);
     12  LockStack (stack);
    1013 
    1114  /* look for first NEEDHOST matching this host */
     
    1821    }
    1922    if (strcasecmp (job[0].hostname, host[0].hostname)) continue;
    20     LinkJobAndHost (job, host);
     23
     24    /* we have found an appropriate job; link it to the host and send to StartJob */
     25    job[0].host = (struct Host *) host;
     26    host[0].job = (struct Job *) job;
     27
     28    /* take the job off the stack and unlock the stack */
     29    RemoveStackEntry (stack, i);
     30    UnlockStack (stack);
    2131    StartJob (job);
    2232    return (TRUE);
     
    2636  for (i = 0; i < stack[0].Nobject; i++) {
    2737    job = (Job *) stack[0].object[i];
    28     /*** this currently never runs WANTHOST jobs on any other machines ***/
    2938    if (job[0].mode != PCONTROL_JOB_WANTHOST) continue;
    3039    if (job[0].hostname == NULL) {
     
    3342    }
    3443    if (strcasecmp (job[0].hostname, host[0].hostname)) continue;
    35     LinkJobAndHost (job, host);
     44
     45    /* we have found an appropriate job; link it to the host and send to StartJob */
     46    job[0].host = (struct Host *) host;
     47    host[0].job = (struct Job *) job;
     48
     49    /* take the job off the stack and unlock the stack */
     50    RemoveStackEntry (stack, i);
     51    UnlockStack (stack);
    3652    StartJob (job);
    3753    return (TRUE);
     
    4258    job = (Job *) stack[0].object[i];
    4359    if (job[0].mode != PCONTROL_JOB_ANYHOST) continue;
    44     LinkJobAndHost (job, host);
     60
     61    /* we have found an appropriate job; link it to the host and send to StartJob */
     62    job[0].host = (struct Host *) host;
     63    host[0].job = (struct Job *) job;
     64
     65    /* take the job off the stack and unlock the stack */
     66    RemoveStackEntry (stack, i);
     67    UnlockStack (stack);
    4568    StartJob (job);
    46     return (TRUE);
     69   return (TRUE);
    4770  }
    48   /* no jobs for host, but back on IDLE stack */
     71
     72  /* no ANYHOST entry, look for first WANTHOST with old time */
     73  /* XXX perhaps I should add this to the conditions for ANYHOST instead of
     74     running a separate loop?  ie, WANTHOST && time > X == ANYHOST */
     75  for (i = 0; i < stack[0].Nobject; i++) {
     76    job = (Job *) stack[0].object[i];
     77    if (job[0].mode != PCONTROL_JOB_WANTHOST) continue;
     78    // test the job age and skip if too young
     79
     80    /* we have found an appropriate job; link it to the host and send to StartJob */
     81    job[0].host = (struct Host *) host;
     82    host[0].job = (struct Job *) job;
     83
     84    /* take the job off the stack and unlock the stack */
     85    RemoveStackEntry (stack, i);
     86    UnlockStack (stack);
     87    StartJob (job);
     88   return (TRUE);
     89  }
     90  UnlockStack (stack);
     91
     92  /* no jobs for host, put it back on IDLE stack */
    4993  PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM);
    5094  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.