Changeset 18098 for trunk/Ohana/src/opihi/pcontrol/host.c
- Timestamp:
- Jun 12, 2008, 12:52:06 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/host.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/host.c
r10652 r18098 1 1 # include "pcontrol.h" 2 2 3 // we use CheckPoints in this function to prevent objects in flight from being missing.4 3 int host (int argc, char **argv) { 5 4 6 int StackID;7 5 IDtype HostID; 8 6 Host *host; 7 Stack *AllHosts; 9 8 10 9 if (argc != 3) goto usage; 10 11 AllHosts = GetHostStack (PCONTROL_HOST_ALLHOSTS); 11 12 12 13 if (!strcasecmp (argv[1], "ADD")) { … … 15 16 return (TRUE); 16 17 } 18 19 // this one is safe from in-flight entries: no one else pulls from OFF 17 20 if (!strcasecmp (argv[1], "ON")) { 18 21 host = PullHostFromStackByName (PCONTROL_HOST_OFF, argv[2]); … … 25 28 return (TRUE); 26 29 } 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 27 33 if (!strcasecmp (argv[1], "RETRY")) { 28 34 // 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]); 30 36 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) { 31 41 gprint (GP_LOG, "host %s is not DOWN\n", argv[2]); 32 42 return (FALSE); 33 43 } 34 /* reset time, place back on DOWNstack */44 /* reset time, place back on ALLHOSTS stack */ 35 45 host[0].nexttry.tv_sec = 0; 36 46 host[0].nexttry.tv_usec = 0; 37 47 host[0].lasttry.tv_sec = 0; 38 48 host[0].lasttry.tv_usec = 0; 39 Pu tHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);49 PushStack (AllHosts, STACK_BOTTOM, host, host[0].HostID, host[0].hostname); 40 50 return (TRUE); 41 51 } 52 42 53 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]); 45 55 if (host == NULL) { 46 56 gprint (GP_LOG, "host %s not found\n", argv[2]); 47 ClearCheckPoint ();48 57 return (FALSE); 49 58 } 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); 54 61 return (TRUE); 55 62 } 63 56 64 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]); 59 66 if (host == NULL) { 60 67 gprint (GP_LOG, "host %s not found\n", argv[2]); 61 ClearCheckPoint ();62 68 return (FALSE); 63 69 } 64 70 host[0].markoff = TRUE; 65 PutHost (host, StackID, STACK_BOTTOM); 66 ClearCheckPoint (); 71 PushStack (AllHosts, STACK_BOTTOM, host, host[0].HostID, host[0].hostname); 67 72 return (TRUE); 68 73 } 69 74 75 // this one is safe from in-flight entries: no one else pulls from OFF 70 76 if (!strcasecmp (argv[1], "DELETE")) { 71 // a check point is not required: no possible thief72 77 host = PullHostFromStackByName (PCONTROL_HOST_OFF, argv[2]); 73 78 if (!host) {
Note:
See TracChangeset
for help on using the changeset viewer.
