Changeset 4697
- Timestamp:
- Aug 2, 2005, 9:40:50 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 deleted
- 16 edited
-
cmd.data/push.c (modified) (2 diffs)
-
include/data.h (modified) (2 diffs)
-
include/inherent.h (deleted)
-
include/psched.h (modified) (3 diffs)
-
lib.data/IOBufferOps.c (modified) (2 diffs)
-
lib.data/Makefile (modified) (1 diff)
-
lib.data/convert.c (modified) (1 diff)
-
lib.data/queues.c (modified) (2 diffs)
-
lib.shell/Makefile (modified) (1 diff)
-
pantasks/CheckJobs.c (modified) (2 diffs)
-
pantasks/CheckTasks.c (modified) (1 diff)
-
pantasks/ControllerOps.c (modified) (3 diffs)
-
pantasks/LocalJob.c (modified) (2 diffs)
-
pantasks/TaskOps.c (modified) (3 diffs)
-
pantasks/task.c (modified) (4 diffs)
-
pantasks/task_command.c (modified) (1 diff)
-
scripts/sched.pro (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/push.c
r2598 r4697 3 3 int push (int argc, char **argv) { 4 4 5 int N, Unique, Replace, Key; 5 6 Queue *queue; 6 7 8 Unique = FALSE; 9 if ((N = get_argument (argc, argv, "-uniq"))) { 10 remove_argument (N, &argc, argv); 11 Unique = TRUE; 12 } 13 14 Replace = FALSE; 15 if ((N = get_argument (argc, argv, "-replace"))) { 16 remove_argument (N, &argc, argv); 17 Replace = TRUE; 18 } 19 20 Key = -1; 21 if ((N = get_argument (argc, argv, "-key"))) { 22 remove_argument (N, &argc, argv); 23 Key = atoi (argv[N]); 24 remove_argument (N, &argc, argv); 25 } 26 7 27 if (argc != 3) { 8 fprintf (stderr, "USAGE: push (queue) (value) \n");28 fprintf (stderr, "USAGE: push (queue) (value) [-key N] [-uniq] [-replace]\n"); 9 29 return (FALSE); 10 30 } … … 12 32 /* will create a queue if none exists */ 13 33 queue = CreateQueue (argv[1]); 14 PushQueue (queue, argv[2]); 34 35 if (Unique) { 36 PushQueueUnique (queue, argv[2], Key); 37 } 38 if (Replace) { 39 PushQueueReplace (queue, argv[2], Key); 40 } 41 if (!Unique && !Replace) { 42 PushQueue (queue, argv[2]); 43 } 15 44 return (TRUE); 16 45 } -
trunk/Ohana/src/opihi/include/data.h
r4693 r4697 31 31 int FlushIOBuffer (IOBuffer *buffer); 32 32 int ReadtoIOBuffer (IOBuffer *buffer, int fd); 33 int EmptyIOBuffer (IOBuffer *buffer, int Nmax, int fd); 33 34 void FreeIOBuffer (IOBuffer *buffer); 34 35 … … 39 40 Queue *CreateQueue (char *name); 40 41 void PushQueue (Queue *queue, char *line); 42 void PushNamedQueue (char *name, char *line); 41 43 char *PopQueue (Queue *queue); 44 void PushQueueUnique (Queue *queue, char *line, int Key); 45 void PushQueueReplace (Queue *queue, char *line, int Key); 42 46 43 47 /* in sort.c */ -
trunk/Ohana/src/opihi/include/psched.h
r4693 r4697 23 23 24 24 enum {RANGE_ABS, RANGE_DAY, RANGE_WEEK}; 25 26 enum {TASK_NONE, 27 TASK_EMPTY, 28 TASK_COMMENT, 29 TASK_NMAX, 30 TASK_TRANGE, 31 TASK_END, 32 TASK_HOST, 33 TASK_COMMAND, 34 TASK_PERIODS, 35 TASK_EXIT, 36 TASK_EXEC 37 } TaskHashResults; 25 38 26 39 typedef struct { … … 91 104 JobMode mode; /* local or controller? */ 92 105 93 int stdout_size; /* s tdout pipe (local only) */94 int stderr_size; /* s tderr pipe (local only) */106 int stdout_size; /* size of pending stdout buffer (controller) */ 107 int stderr_size; /* size of pending stderr buffer (controller) */ 95 108 int stdout_fd; /* stdout pipe (local only) */ 96 109 int stderr_fd; /* stderr pipe (local only) */ … … 110 123 int FreeTask (Task *task); 111 124 Task *CreateTask (char *name); 112 int ValidateTask (Task *task );125 int ValidateTask (Task *task, int RequireStatic); 113 126 int RegisterNewTask (); 114 127 int DeleteNewTask (); 115 128 Task *GetNewTask (); 129 Task *GetActiveTask (); 116 130 void SetTaskTimer (struct timeval *timer); 117 131 double GetTaskTimer (struct timeval start); -
trunk/Ohana/src/opihi/lib.data/IOBufferOps.c
r4693 r4697 1 # include " pclient.h"1 # include "data.h" 2 2 3 3 int InitIOBuffer (IOBuffer *buffer, int Nalloc) { … … 61 61 } 62 62 63 /* read until buffer is empty (Nmax retries) */ 64 int EmptyIOBuffer (IOBuffer *buffer, int Nmax, int fd) { 65 66 int i, status; 67 68 status = -1; 69 for (i = 0; (status != 0) && (i < Nmax); i++) { 70 status = ReadtoIOBuffer (buffer, fd); 71 if (status == -1) usleep (10000); 72 if (status > 0) i = 0; 73 } 74 if (status == -1) return (FALSE); 75 return (TRUE); 76 } 77 63 78 void FreeIOBuffer (IOBuffer *buffer) { 64 79 -
trunk/Ohana/src/opihi/lib.data/Makefile
r4693 r4697 36 36 $(SDIR)/open_graph.$(ARCH).o \ 37 37 $(SDIR)/open_image.$(ARCH).o \ 38 $(SDIR)/queues.$(ARCH).o \ 38 39 $(SDIR)/IOBufferOps.$(ARCH).o \ 39 40 $(SDIR)/PlotVectors.$(ARCH).o -
trunk/Ohana/src/opihi/lib.data/convert.c
r4689 r4697 1 1 # include "convert.h" 2 # define _XOPEN_SOURCE /* glibc2 needs this */2 # define _XOPEN_SOURCE /* glibc2 (strptime) needs this */ 3 3 # include <time.h> 4 4 -
trunk/Ohana/src/opihi/lib.data/queues.c
r4693 r4697 1 # include " opihi.h"1 # include "data.h" 2 2 3 3 /* These functions are somewhat fragile: we cannot do multiple CreateQueue … … 56 56 } 57 57 58 void PushNamedQueue (char *name, char *line) { 59 60 Queue *queue; 61 62 queue = FindQueue (name); 63 if (queue == NULL) { 64 queue = CreateQueue (name); 65 } 66 PushQueue (queue, line); 67 return; 68 } 69 70 /* push line onto queue. return chars create new lines */ 58 71 void PushQueue (Queue *queue, char *line) { 59 72 60 73 int N; 61 74 char *p, *q; 75 76 p = line; 77 q = strchr (line, '\n'); 62 78 N = queue[0].Nlines; 63 queue[0].lines[N] = strcreate (line); 64 queue[0].Nlines ++; 65 if (queue[0].Nlines == queue[0].NLINES) { 66 queue[0].NLINES += 10; 67 REALLOCATE (queue[0].lines, char *, queue[0].NLINES); 68 } 79 while (q != NULL) { 80 queue[0].lines[N] = strncreate (p, q - p); 81 N++; 82 CHECK_REALLOCATE (queue[0].lines, char *, queue[0].NLINES, N, 16); 83 p = q + 1; 84 q = strchr (p, '\n'); 85 } 86 if (*p) { 87 queue[0].lines[N] = strcreate (p); 88 N++; 89 CHECK_REALLOCATE (queue[0].lines, char *, queue[0].NLINES, N, 16); 90 } 91 queue[0].Nlines = N; 92 return; 93 } 94 95 char *ChooseKey (char *line, int Key) { 96 97 int i; 98 char *key, *p; 99 100 key = line; 101 if (Key != -1) { 102 for (i = 0; (i < Key) && (key != NULL); i++) { 103 p = nextword (key); 104 key = p; 105 } 106 key = thisword (key); 107 } 108 return (key); 109 } 110 111 /* push line onto queue, skipping existing matches (optionally by key) */ 112 void PushQueueUnique (Queue *queue, char *line, int Key) { 113 114 int i, j, N, found; 115 char *p, *q, *key1, *key2; 116 Queue tmp; 117 118 /* init tmp queue */ 119 tmp.Nlines = 0; 120 tmp.NLINES = 16; 121 ALLOCATE (tmp.lines, char *, tmp.NLINES); 122 123 /* push entries on tmp queue */ 124 p = line; 125 q = strchr (line, '\n'); 126 N = tmp.Nlines; 127 while (q != NULL) { 128 tmp.lines[N] = strncreate (p, q - p); 129 N++; 130 CHECK_REALLOCATE (tmp.lines, char *, tmp.NLINES, N, 16); 131 p = q + 1; 132 q = strchr (p, '\n'); 133 } 134 if (*p) { 135 tmp.lines[N] = strcreate (p); 136 N++; 137 CHECK_REALLOCATE (tmp.lines, char *, tmp.NLINES, N, 16); 138 } 139 tmp.Nlines = N; 140 141 /* add unique entries in tmp to queue */ 142 for (i = 0; i < tmp.Nlines; i++) { 143 key1 = ChooseKey (tmp.lines[i], Key); 144 if (key1 == NULL) continue; 145 found = FALSE; 146 for (j = 0; !found && (j < queue[0].Nlines); j++) { 147 key2 = ChooseKey (queue[0].lines[j], Key); 148 if (key2 == NULL) continue; 149 if (strcmp (key1, key2)) { 150 if (Key != -1) free (key2); 151 continue; 152 } 153 found = TRUE; 154 if (Key != -1) free (key2); 155 } 156 if (!found) PushQueue (queue, tmp.lines[i]); 157 if (Key != -1) free (key1); 158 } 159 for (i = 0; i < tmp.Nlines; i++) { 160 free (tmp.lines[i]); 161 } 162 free (tmp.lines); 163 return; 164 } 165 166 /* push line onto queue, replacing matches (optionally by Key) */ 167 void PushQueueReplace (Queue *queue, char *line, int Key) { 168 169 int i, j, N, found; 170 char *p, *q, *key1, *key2; 171 Queue tmp; 172 173 /* init tmp queue */ 174 tmp.Nlines = 0; 175 tmp.NLINES = 16; 176 ALLOCATE (tmp.lines, char *, tmp.NLINES); 177 178 /* push entries on tmp queue */ 179 p = line; 180 q = strchr (line, '\n'); 181 N = tmp.Nlines; 182 while (q != NULL) { 183 tmp.lines[N] = strncreate (p, q - p); 184 N++; 185 CHECK_REALLOCATE (tmp.lines, char *, tmp.NLINES, N, 16); 186 p = q + 1; 187 q = strchr (p, '\n'); 188 } 189 if (*p) { 190 tmp.lines[N] = strcreate (p); 191 N++; 192 CHECK_REALLOCATE (tmp.lines, char *, tmp.NLINES, N, 16); 193 } 194 tmp.Nlines = N; 195 196 /* add unique entries in tmp to queue */ 197 for (i = 0; i < tmp.Nlines; i++) { 198 key1 = ChooseKey (tmp.lines[i], Key); 199 if (key1 == NULL) continue; 200 found = FALSE; 201 for (j = 0; !found && (j < queue[0].Nlines); j++) { 202 key2 = ChooseKey (queue[0].lines[j], Key); 203 if (key2 == NULL) continue; 204 if (strcmp (key1, key2)) { 205 if (Key != -1) free (key2); 206 continue; 207 } 208 queue[0].lines[j] = strcreate (tmp.lines[i]); 209 found = TRUE; 210 if (Key != -1) free (key2); 211 } 212 if (!found) PushQueue (queue, tmp.lines[i]); 213 if (Key != -1) free (key1); 214 } 215 for (i = 0; i < tmp.Nlines; i++) { 216 free (tmp.lines[i]); 217 } 218 free (tmp.lines); 69 219 return; 70 220 } -
trunk/Ohana/src/opihi/lib.shell/Makefile
r4689 r4697 55 55 $(SDIR)/dvomath.$(ARCH).o \ 56 56 $(SDIR)/stack_math.$(ARCH).o \ 57 $(SDIR)/queues.$(ARCH).o \58 57 $(SDIR)/variable.$(ARCH).o \ 59 58 $(SDIR)/opihi.$(ARCH).o -
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r4693 r4697 29 29 /* XXX this will break on 0 values in output streams */ 30 30 if (VerboseMode()) fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID); 31 set_str_variable ("stdout", job[0].stdout.buffer);32 set_str_variable ("stderr", job[0].stderr.buffer);31 PushNamedQueue ("stdout", job[0].stdout.buffer); 32 PushNamedQueue ("stderr", job[0].stderr.buffer); 33 33 if (job[0].task[0].crash != NULL) { 34 34 exec_loop (job[0].task[0].crash); … … 40 40 case JOB_EXIT: 41 41 if (VerboseMode()) fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID); 42 set_str_variable ("stdout", job[0].stdout.buffer);43 set_str_variable ("stderr", job[0].stderr.buffer);42 PushNamedQueue ("stdout", job[0].stdout.buffer); 43 PushNamedQueue ("stderr", job[0].stderr.buffer); 44 44 /* run corresponding task[0].exit macro, if it exists */ 45 45 macro = job[0].task[0].def; -
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r4693 r4697 22 22 if (!status) continue; 23 23 } 24 if (!ValidateTask (task, TRUE)) continue; 24 25 25 26 /* construct job from task */ -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r4693 r4697 3 3 # define CONNECT_TIMEOUT 300 4 4 5 /* local static variables to hold the connection to the controller */ 5 6 static int status = FALSE; 6 7 static int stdin_cntl, stdout_cntl, stderr_cntl; … … 8 9 static IOBuffer stderr_buffer; 9 10 11 /* test if the controller is running */ 10 12 int CheckControllerStatus () { 11 13 return (status); 12 14 } 13 15 16 /* check job / get output if done */ 14 17 int CheckControllerJob (Job *job) { 15 18 … … 23 26 } 24 27 28 /* ask controller about job status */ 25 29 int CheckControllerJobStatus (Job *job) { 26 30 -
trunk/Ohana/src/opihi/pantasks/LocalJob.c
r4693 r4697 1 1 # include "psched.h" 2 3 /* local jobs are forked in the background 4 we might need to limit the maximum number of local jobs. 5 should we have a queue/stack of pending local jobs, much 6 like controller? */ 7 8 /* update current state, drain stdout/stderr buffers */ 9 int CheckLocalJob (Job *job) { 10 11 int Nread; 12 13 // XXX do something useful with exit status? 14 CheckLocalJobStatus (job); 15 16 if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) { 17 EmptyIOBuffer (&job[0].stdout, 10, job[0].stdout_fd); 18 EmptyIOBuffer (&job[0].stderr, 10, job[0].stderr_fd); 19 close (job[0].stdout_fd); 20 close (job[0].stderr_fd); 21 } else { 22 /* read stdout buffer */ 23 Nread = ReadtoIOBuffer (&job[0].stdout, job[0].stdout_fd); 24 switch (Nread) { 25 case -2: /* error in read (programming error? system level error?) */ 26 fprintf (stderr, "serious IO error\n"); 27 exit (2); 28 case -1: /* no data in pipe */ 29 case 0: /* pipe is closed, change child state? **/ 30 default: /* data in pipe */ 31 break; 32 } 33 34 /* read stderr buffer */ 35 Nread = ReadtoIOBuffer (&job[0].stderr, job[0].stderr_fd); 36 switch (Nread) { 37 case -2: /* error in read (programming error? system level error?) */ 38 fprintf (stderr, "serious IO error\n"); 39 exit (2); 40 case -1: /* no data in pipe */ 41 case 0: /* pipe is closed, change child state? **/ 42 default: /* data in pipe */ 43 break; 44 } 45 } 46 return (TRUE); 47 } 48 49 int CheckLocalJobStatus (Job *job) { 50 51 int result, waitstatus; 52 53 /* check local job status */ 54 result = waitpid (job[0].pid, &waitstatus, WNOHANG); 55 switch (result) { 56 case -1: /* error with waitpid */ 57 switch (errno) { 58 case ECHILD: 59 fprintf (stderr, "unknown PID, not a child proc\n"); 60 fprintf (stderr, "did process already exit? programming error?\n"); 61 job[0].state = JOB_NONE; 62 job[0].exit_status = 0; 63 return (FALSE); 64 case EINVAL: 65 fprintf (stderr, "error EINVAL (waitpid): programming error\n"); 66 exit (1); 67 case EINTR: 68 fprintf (stderr, "error EINTR (waitpid): programming error\n"); 69 exit (1); 70 default: 71 fprintf (stderr, "unknown error for waitpid (%d): programming error\n", errno); 72 exit (1); 73 } 74 break; 75 76 case 0: /* process not exited */ 77 job[0].state = JOB_BUSY; 78 job[0].exit_status = 0; 79 return (TRUE); 80 81 default: 82 if (result != job[0].pid) { 83 fprintf (stderr, "waitpid error: mis-matched PID (%d vs %d). programming error\n", result, job[0].pid); 84 exit (1); 85 } 86 if (WIFEXITED(waitstatus)) { 87 job[0].state = JOB_EXIT; 88 job[0].exit_status = WEXITSTATUS(waitstatus); 89 } 90 if (WIFSIGNALED(waitstatus)) { 91 job[0].state = JOB_CRASH; 92 job[0].exit_status = WTERMSIG(waitstatus); 93 } 94 if (WIFSTOPPED(waitstatus)) { 95 fprintf (stderr, "waitpid returns 'stopped': programming error\n"); 96 exit (1); 97 } 98 } 99 return (FALSE); 100 } 2 101 3 102 /* this could be written a just a one-way pipe */ … … 58 157 } 59 158 60 /* update current state, drain stdout/stderr buffers */ 61 int CheckLocalJob (Job *job) { 62 63 int Nread; 64 65 // XXX do something useful with exit status? 66 CheckLocalJobStatus (job); 67 68 if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) { 69 EmptyIOBuffer (&job[0].stdout, job[0].stdout_fd); 70 EmptyIOBuffer (&job[0].stderr, job[0].stderr_fd); 71 } else { 72 /* read stdout buffer */ 73 Nread = ReadtoIOBuffer (&job[0].stdout, job[0].stdout_fd); 74 switch (Nread) { 75 case -2: /* error in read (programming error? system level error?) */ 76 fprintf (stderr, "serious IO error\n"); 77 exit (2); 78 case -1: /* no data in pipe */ 79 case 0: /* pipe is closed, change child state? **/ 80 default: /* data in pipe */ 81 break; 82 } 83 84 /* read stderr buffer */ 85 Nread = ReadtoIOBuffer (&job[0].stderr, job[0].stderr_fd); 86 switch (Nread) { 87 case -2: /* error in read (programming error? system level error?) */ 88 fprintf (stderr, "serious IO error\n"); 89 exit (2); 90 case -1: /* no data in pipe */ 91 case 0: /* pipe is closed, change child state? **/ 92 default: /* data in pipe */ 93 break; 94 } 95 } 96 return (TRUE); 97 } 98 99 int CheckLocalJobStatus (Job *job) { 100 101 int result, waitstatus; 102 103 /*** if child has exited, does the pipe hang around until it is flushed? ***/ 104 /*** who closes the child stdout/stderr fd? */ 105 106 /* check local job status */ 107 result = waitpid (job[0].pid, &waitstatus, WNOHANG); 108 switch (result) { 109 case -1: /* error with waitpid */ 110 switch (errno) { 111 case ECHILD: 112 fprintf (stderr, "unknown PID, not a child proc\n"); 113 fprintf (stderr, "did process already exit? programming error?\n"); 114 job[0].state = JOB_NONE; 115 job[0].exit_status = 0; 116 return (FALSE); 117 case EINVAL: 118 fprintf (stderr, "error EINVAL (waitpid): programming error\n"); 119 exit (1); 120 case EINTR: 121 fprintf (stderr, "error EINTR (waitpid): programming error\n"); 122 exit (1); 123 default: 124 fprintf (stderr, "unknown error for waitpid (%d): programming error\n", errno); 125 exit (1); 126 } 127 break; 128 129 case 0: /* process not exited */ 130 job[0].state = JOB_BUSY; 131 job[0].exit_status = 0; 132 return (TRUE); 133 134 default: 135 if (result != job[0].pid) { 136 fprintf (stderr, "waitpid error: mis-matched PID (%d vs %d). programming error\n", result, job[0].pid); 137 exit (1); 138 } 139 if (WIFEXITED(waitstatus)) { 140 job[0].state = JOB_EXIT; 141 job[0].exit_status = WEXITSTATUS(waitstatus); 142 } 143 if (WIFSIGNALED(waitstatus)) { 144 job[0].state = JOB_CRASH; 145 job[0].exit_status = WTERMSIG(waitstatus); 146 } 147 if (WIFSTOPPED(waitstatus)) { 148 fprintf (stderr, "waitpid returns 'stopped': programming error\n"); 149 exit (1); 150 } 151 } 152 return (FALSE); 153 } 154 159 /* should this function close the fd's? */ 155 160 int KillLocalJob (Job *job) { 156 161 -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r4693 r4697 68 68 fprintf (stderr, "- "); 69 69 } 70 fprintf (stderr, "%-15s %4d %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].argv[0]); 70 if (tasks[i][0].argv == NULL) { 71 fprintf (stderr, "%-15s %4d %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, "dynamic"); 72 } else { 73 fprintf (stderr, "%-15s %4d %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].argv[0]); 74 } 71 75 if (verbose) { 72 76 fprintf (stderr, " spawn period: %f, polling period: %f, timeout period: %f\n", … … 209 213 } 210 214 211 int ValidateTask (Task *task) { 212 213 if (task[0].argc == 0) { 215 int ValidateTask (Task *task, int RequireStatic) { 216 217 int i, hash; 218 219 /* is a static command defined? */ 220 if (task[0].argc != 0) { 221 if (task[0].argv == NULL) { 222 fprintf (stderr, "task command arguments not defined (programming error)\n"); 223 return (FALSE); 224 } 225 return (TRUE); 226 } 227 if (RequireStatic) { 214 228 fprintf (stderr, "task command not defined\n"); 215 229 return (FALSE); 216 230 } 217 if (task[0].argv == NULL) { 218 fprintf (stderr, "task command arguments not defined (programming error)\n"); 219 return (FALSE); 220 } 221 return (TRUE); 231 232 /* no static command; dynamic command? */ 233 if (task[0].exec != NULL) { 234 for (i = 0; i < task[0].exec[0].Nlines; i++) { 235 hash = TaskHash (task[0].exec[0].line[i]); 236 if (hash == TASK_COMMAND) return (TRUE); 237 } 238 } 239 fprintf (stderr, "task command not defined\n"); 240 return (FALSE); 222 241 } 223 242 … … 250 269 } 251 270 271 Task *GetActiveTask () { 272 Task *task; 273 if (ActiveTask < 0) return (NULL); 274 task = tasks[ActiveTask]; 275 return (task); 276 } 277 278 int TaskHash (char *input) { 279 280 int hash; 281 char *command; 282 283 hash = TASK_NONE; 284 285 command = thisword (input); 286 if (command == NULL) return (TASK_EMPTY); 287 288 if (command[0] == '#') hash = TASK_COMMENT; 289 if (!strcasecmp (command, "END")) hash = TASK_END; 290 if (!strcasecmp (command, "HOST")) hash = TASK_HOST; 291 if (!strcasecmp (command, "NMAX")) hash = TASK_NMAX; 292 if (!strcasecmp (command, "TRANGE")) hash = TASK_TRANGE; 293 if (!strcasecmp (command, "COMMAND")) hash = TASK_COMMAND; 294 if (!strcasecmp (command, "PERIODS")) hash = TASK_PERIODS; 295 if (!strcasecmp (command, "TASK.EXIT")) hash = TASK_EXIT; 296 if (!strcasecmp (command, "TASK.EXEC")) hash = TASK_EXEC; 297 298 free (command); 299 return (hash); 300 } 301 252 302 /*** task timer functions ***/ 253 303 -
trunk/Ohana/src/opihi/pantasks/task.c
r4693 r4697 2 2 # define prompt "> " 3 3 4 enum {TASK_NONE, TASK_EMPTY, TASK_COMMENT, TASK_NMAX, TASK_TRANGE, TASK_END, TASK_HOST, TASK_COMMAND, TASK_PERIODS, TASK_EXIT, TASK_EXEC};5 6 4 int task (int argc, char **argv) { 7 5 8 int N ;6 int N, hash; 9 7 int ThisList, status; 10 8 char *input, *outline; … … 66 64 67 65 stripwhite (input); 68 switch (TaskHash (input)) { 66 hash = TaskHash (input); 67 switch (hash) { 69 68 70 69 case TASK_EMPTY: … … 78 77 free (input); 79 78 /* validate the new task: all mandatory elements defined? */ 80 if (!ValidateTask (task )) {79 if (!ValidateTask (task, FALSE)) { 81 80 DeleteNewTask (); 82 81 return (FALSE); … … 107 106 return (FALSE); 108 107 } 109 110 int TaskHash (char *input) {111 112 int hash;113 char *command;114 115 hash = TASK_NONE;116 117 command = thisword (input);118 if (command == NULL) return (TASK_EMPTY);119 120 if (command[0] == '#') hash = TASK_COMMENT;121 if (!strcasecmp (command, "END")) hash = TASK_END;122 if (!strcasecmp (command, "HOST")) hash = TASK_HOST;123 if (!strcasecmp (command, "NMAX")) hash = TASK_NMAX;124 if (!strcasecmp (command, "TRANGE")) hash = TASK_TRANGE;125 if (!strcasecmp (command, "COMMAND")) hash = TASK_COMMAND;126 if (!strcasecmp (command, "PERIODS")) hash = TASK_PERIODS;127 if (!strcasecmp (command, "TASK.EXIT")) hash = TASK_EXIT;128 if (!strcasecmp (command, "TASK.EXEC")) hash = TASK_EXEC;129 130 free (command);131 return (hash);132 } -
trunk/Ohana/src/opihi/pantasks/task_command.c
r4693 r4697 14 14 task = GetNewTask (); 15 15 if (task == NULL) { 16 fprintf (stderr, "ERROR: not defining or running a task\n"); 17 return (FALSE); 16 task = GetActiveTask (); 17 if (task == NULL) { 18 fprintf (stderr, "ERROR: not defining or running a task\n"); 19 return (FALSE); 20 } 18 21 } 19 22 -
trunk/Ohana/src/opihi/scripts/sched.pro
r4693 r4697 3 3 4 4 task test 5 command ls /data/eugene5 command ls 6 6 periods -poll 1.0 7 periods -exec 5.07 periods -exec 2.0 8 8 periods -timeout 10.0 9 9 # trange 07:09 07:10 … … 18 18 end 19 19 20 # stdout / stderr lines on named queues 20 21 task.exit 0 21 # note that $stdout/$stderr may contain return characters 22 # which will interfere with 'exec' 23 # push ls.list $stdout 24 echo $stdout 22 echo "task exit 0" 23 queuesize stdout 24 queuesize stderr 25 25 end 26 26 27 27 task.exit 1 28 output failure.log29 echo $stdout30 output stdout28 echo "task exit 1" 29 queuesize stdout 30 queuesize stderr 31 31 end 32 32
Note:
See TracChangeset
for help on using the changeset viewer.
