IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2008, 12:52:06 PM (18 years ago)
Author:
eugene
Message:

use virtual stacks for host and job queries by user thread

File:
1 edited

Legend:

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

    r10652 r18098  
    11# include "pcontrol.h"
    22
    3 // we use CheckPoints in this function to prevent objects in flight from being missing.
    43int host (int argc, char **argv) {
    54
    6   int StackID;
    75  IDtype HostID;
    86  Host *host;
     7  Stack *AllHosts;
    98
    109  if (argc != 3) goto usage;
     10
     11  AllHosts = GetHostStack (PCONTROL_HOST_ALLHOSTS);
    1112
    1213  if (!strcasecmp (argv[1], "ADD")) {
     
    1516    return (TRUE);
    1617  }
     18
     19  // this one is safe from in-flight entries: no one else pulls from OFF
    1720  if (!strcasecmp (argv[1], "ON")) {
    1821    host = PullHostFromStackByName (PCONTROL_HOST_OFF, argv[2]);
     
    2528    return (TRUE);
    2629  }
     30
     31  // this is a race condition with "CheckDownHosts", but the only
     32  // consequence is that both StartHost and reset set the times to 0.0
    2733  if (!strcasecmp (argv[1], "RETRY")) {
    2834    // no need to use a check point [thief: CheckDownHost (DOWN->IDLE)]
    29     host = PullHostFromStackByName (PCONTROL_HOST_DOWN, argv[2]);
     35    host = PullHostFromStackByName (PCONTROL_HOST_ALLHOSTS, argv[2]);
    3036    if (!host) {
     37      gprint (GP_LOG, "host %s not found\n", argv[2]);
     38      return (FALSE);
     39    }
     40    if (host[0].stack != PCONTROL_HOST_DOWN) {
    3141      gprint (GP_LOG, "host %s is not DOWN\n", argv[2]);
    3242      return (FALSE);
    3343    }
    34     /* reset time, place back on DOWN stack */
     44    /* reset time, place back on ALLHOSTS stack */
    3545    host[0].nexttry.tv_sec  = 0;
    3646    host[0].nexttry.tv_usec = 0;
    3747    host[0].lasttry.tv_sec  = 0;
    3848    host[0].lasttry.tv_usec = 0;
    39     PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
     49    PushStack (AllHosts, STACK_BOTTOM, host, host[0].HostID, host[0].hostname);
    4050    return (TRUE);
    4151  }
     52
    4253  if (!strcasecmp (argv[1], "CHECK")) {
    43     SetCheckPoint ();  // ensure the host is on one of the stacks
    44     host = PullHostByName (argv[2], &StackID);
     54    host = PullHostFromStackByName (PCONTROL_HOST_ALLHOSTS, argv[2]);
    4555    if (host == NULL) {
    4656      gprint (GP_LOG, "host %s not found\n", argv[2]);
    47       ClearCheckPoint ();
    4857      return (FALSE);
    4958    }
    50     PutHost (host, StackID, STACK_BOTTOM);
    51     ClearCheckPoint ();
    52 
    53     gprint (GP_LOG, "host %s is %s\n", argv[2], GetHostStackName (StackID));
     59    gprint (GP_LOG, "host %s is %s\n", argv[2], GetHostStackName (host[0].stack));
     60    PushStack (AllHosts, STACK_BOTTOM, host, host[0].HostID, host[0].hostname);
    5461    return (TRUE);
    5562  }
     63
    5664  if (!strcasecmp (argv[1], "OFF")) {
    57     SetCheckPoint (); // ensure we can find the specified host
    58     host = PullHostByName (argv[2], &StackID);
     65    host = PullHostFromStackByName (PCONTROL_HOST_ALLHOSTS, argv[2]);
    5966    if (host == NULL) {
    6067      gprint (GP_LOG, "host %s not found\n", argv[2]);
    61       ClearCheckPoint ();
    6268      return (FALSE);
    6369    }
    6470    host[0].markoff = TRUE;
    65     PutHost (host, StackID, STACK_BOTTOM);
    66     ClearCheckPoint ();
     71    PushStack (AllHosts, STACK_BOTTOM, host, host[0].HostID, host[0].hostname);
    6772    return (TRUE);
    6873  }
    6974
     75  // this one is safe from in-flight entries: no one else pulls from OFF
    7076  if (!strcasecmp (argv[1], "DELETE")) {
    71     // a check point is not required: no possible thief
    7277    host = PullHostFromStackByName (PCONTROL_HOST_OFF, argv[2]);
    7378    if (!host) {
Note: See TracChangeset for help on using the changeset viewer.