IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2005, 9:34:34 AM (21 years ago)
Author:
eugene
Message:

pcontrol dev

File:
1 edited

Legend:

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

    r3189 r3203  
    11# include "pcontrol.h"
    22
    3 Queue *HostPool_Idle;
    4 Queue *HostPool_Busy;
    5 Queue *HostPool_Down;
    6 Queue *HostPool_Off;
     3Stack *HostPool_Idle;
     4Stack *HostPool_Busy;
     5Stack *HostPool_Down;
     6Stack *HostPool_Off;
    77
    8 Queue *GetHostQueue (int QueueID) {
    9   switch (QueueID) {
     8void InitHostStacks () {
     9  HostPool_Idle = InitStack ();
     10  HostPool_Busy = InitStack ();
     11  HostPool_Down = InitStack ();
     12  HostPool_Off = InitStack ();
     13}
     14
     15Stack *GetHostStack (int StackID) {
     16  switch (StackID) {
    1017    case PCONTROL_HOST_IDLE:
    1118      return (HostPool_Idle);
     
    1724      return (HostPool_Off);
    1825    default:
    19       fprintf (stderr, "error: unknown host queue\n");
     26      fprintf (stderr, "error: unknown host stack\n");
    2027      return (NULL);
    2128  }
     
    2330}
    2431
    25 int PutHost (Host *host, int QueueID, int where) {
     32int PutHost (Host *host, int StackID, int where) {
    2633
    2734  int status;
    28   Queue *queue;
     35  Stack *stack;
    2936
    30   queue = GetHostQueue (QueueID);
    31   if (queue == NULL) return (FALSE);
     37  stack = GetHostStack (StackID);
     38  if (stack == NULL) return (FALSE);
    3239
    33   host[0].status = QueueID;
    34   status = PutObject (queue, where, host);
     40  host[0].stack = StackID;
     41  status = PutStack (stack, where, host);
    3542  return (status);
    3643}
    3744 
    38 Host *GetHost (int QueueID, int where) {
     45Host *GetHost (int StackID, int where) {
    3946
    4047  Host *host;
    41   Queue *queue;
     48  Stack *stack;
    4249
    43   queue = GetHostQueue (QueueID);
    44   if (queue == NULL) return (NULL);
     50  stack = GetHostStack (StackID);
     51  if (stack == NULL) return (NULL);
    4552
    46   host = GetObject (queue, where);
     53  host = GetStack (stack, where);
    4754  return (host);
    4855}
    4956
    50 int FindHost (IDtype HostID, int QueueID) {
     57int FindHost (IDtype HostID, int StackID) {
    5158
    52   Queue *queue;
     59  int i;
     60  Host *host;
     61  Stack *stack;
    5362
    54   queue = GetHostQueue (QueueID);
    55   if (queue == NULL) return (-2);
     63  stack = GetHostStack (StackID);
     64  if (stack == NULL) return (-2);
    5665
    57   for (i = 0; i < queue[0].Nobject; i++) {
    58     host = (Host *) queue[0].object;
     66  for (i = 0; i < stack[0].Nobject; i++) {
     67    host = (Host *) stack[0].object;
    5968    if (host[0].HostID == HostID) {
    6069      return (i);
     
    6473}
    6574
    66 int FindNamedHost (char *name, int QueueID) {
     75int FindNamedHost (char *name, int StackID) {
    6776
    68   Queue *queue;
     77  int i;
     78  Host *host;
     79  Stack *stack;
    6980
    70   queue = GetHostQueue (QueueID);
    71   if (queue == NULL) return (-2);
     81  stack = GetHostStack (StackID);
     82  if (stack == NULL) return (-2);
    7283
    73   for (i = 0; i < queue[0].Nobject; i++) {
    74     host = (Host *) queue[0].object;
    75     if (!strcasecmp (host[0].hostname, host)) {
     84  for (i = 0; i < stack[0].Nobject; i++) {
     85    host = (Host *) stack[0].object;
     86    if (!strcasecmp (host[0].hostname, name)) {
    7687      return (i);
    7788    }
     
    8091}
    8192
    82 AddHost (char *hostname) {
     93void AddHost (char *hostname) {
    8394
    8495  Host *host;
     
    94105  host[0].markoff  = FALSE;
    95106  host[0].job      = NULL;
    96   DownHost (host);
     107  PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    97108}
    98109
    99 DelHost (Host *host) {
     110void DownHost (Host *host) {
     111
     112  CLOSE (host[0].stdin);
     113  CLOSE (host[0].stdout);
     114  CLOSE (host[0].stderr);
     115  host[0].job = NULL;
     116  PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
     117}
     118
     119void DelHost (Host *host) {
    100120  FREE (host[0].hostname);
    101121  FREE (host[0].job);
     
    103123}
    104124
    105 MarkOffHost (Host *host) {
    106   if (host[0].status != PCONTROL_HOST_BUSY) {
    107     return (FALSE);
    108   }
    109   host[0].markoff  = TRUE;
    110   PutObject (HostPool_Busy, host);  /**** where are we removing hosts? **/
    111 }
    112 
Note: See TracChangeset for help on using the changeset viewer.