Changeset 3203 for trunk/Ohana/src/opihi/pcontrol/HostOps.c
- Timestamp:
- Feb 12, 2005, 9:34:34 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/HostOps.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/HostOps.c
r3189 r3203 1 1 # include "pcontrol.h" 2 2 3 Queue*HostPool_Idle;4 Queue*HostPool_Busy;5 Queue*HostPool_Down;6 Queue*HostPool_Off;3 Stack *HostPool_Idle; 4 Stack *HostPool_Busy; 5 Stack *HostPool_Down; 6 Stack *HostPool_Off; 7 7 8 Queue *GetHostQueue (int QueueID) { 9 switch (QueueID) { 8 void InitHostStacks () { 9 HostPool_Idle = InitStack (); 10 HostPool_Busy = InitStack (); 11 HostPool_Down = InitStack (); 12 HostPool_Off = InitStack (); 13 } 14 15 Stack *GetHostStack (int StackID) { 16 switch (StackID) { 10 17 case PCONTROL_HOST_IDLE: 11 18 return (HostPool_Idle); … … 17 24 return (HostPool_Off); 18 25 default: 19 fprintf (stderr, "error: unknown host queue\n");26 fprintf (stderr, "error: unknown host stack\n"); 20 27 return (NULL); 21 28 } … … 23 30 } 24 31 25 int PutHost (Host *host, int QueueID, int where) {32 int PutHost (Host *host, int StackID, int where) { 26 33 27 34 int status; 28 Queue *queue;35 Stack *stack; 29 36 30 queue = GetHostQueue (QueueID);31 if ( queue== NULL) return (FALSE);37 stack = GetHostStack (StackID); 38 if (stack == NULL) return (FALSE); 32 39 33 host[0].sta tus = QueueID;34 status = Put Object (queue, where, host);40 host[0].stack = StackID; 41 status = PutStack (stack, where, host); 35 42 return (status); 36 43 } 37 44 38 Host *GetHost (int QueueID, int where) {45 Host *GetHost (int StackID, int where) { 39 46 40 47 Host *host; 41 Queue *queue;48 Stack *stack; 42 49 43 queue = GetHostQueue (QueueID);44 if ( queue== NULL) return (NULL);50 stack = GetHostStack (StackID); 51 if (stack == NULL) return (NULL); 45 52 46 host = Get Object (queue, where);53 host = GetStack (stack, where); 47 54 return (host); 48 55 } 49 56 50 int FindHost (IDtype HostID, int QueueID) {57 int FindHost (IDtype HostID, int StackID) { 51 58 52 Queue *queue; 59 int i; 60 Host *host; 61 Stack *stack; 53 62 54 queue = GetHostQueue (QueueID);55 if ( queue== NULL) return (-2);63 stack = GetHostStack (StackID); 64 if (stack == NULL) return (-2); 56 65 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; 59 68 if (host[0].HostID == HostID) { 60 69 return (i); … … 64 73 } 65 74 66 int FindNamedHost (char *name, int QueueID) {75 int FindNamedHost (char *name, int StackID) { 67 76 68 Queue *queue; 77 int i; 78 Host *host; 79 Stack *stack; 69 80 70 queue = GetHostQueue (QueueID);71 if ( queue== NULL) return (-2);81 stack = GetHostStack (StackID); 82 if (stack == NULL) return (-2); 72 83 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)) { 76 87 return (i); 77 88 } … … 80 91 } 81 92 82 AddHost (char *hostname) {93 void AddHost (char *hostname) { 83 94 84 95 Host *host; … … 94 105 host[0].markoff = FALSE; 95 106 host[0].job = NULL; 96 DownHost (host);107 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 97 108 } 98 109 99 DelHost (Host *host) { 110 void 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 119 void DelHost (Host *host) { 100 120 FREE (host[0].hostname); 101 121 FREE (host[0].job); … … 103 123 } 104 124 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.
