Changeset 6249
- Timestamp:
- Jan 29, 2006, 9:36:21 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 7 edited
-
cmd.data/queuepop.c (modified) (3 diffs)
-
include/psched.h (modified) (1 diff)
-
lib.data/queues.c (modified) (2 diffs)
-
lib.shell/check_stack.c (modified) (1 diff)
-
pantasks/CheckJobs.c (modified) (5 diffs)
-
pantasks/TaskOps.c (modified) (1 diff)
-
pantasks/task_periods.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/queuepop.c
r4703 r6249 3 3 int queuepop (int argc, char **argv) { 4 4 5 int N ;5 int N, Key; 6 6 char *var; 7 7 char *line; 8 char *Value; 8 9 Queue *queue; 9 10 … … 15 16 } 16 17 18 Key = -1; 19 if ((N = get_argument (argc, argv, "-key"))) { 20 remove_argument (N, &argc, argv); 21 Key = atoi (argv[N]); 22 remove_argument (N, &argc, argv); 23 Value = strcreate (argv[N]); 24 remove_argument (N, &argc, argv); 25 } 26 27 17 28 if (argc != 2) { 18 fprintf (stderr, "USAGE: queuepop (queue) [-var variable] \n");29 fprintf (stderr, "USAGE: queuepop (queue) [-var variable] [-key N value]\n"); 19 30 return (FALSE); 20 31 } … … 27 38 } 28 39 29 line = PopQueue (queue);30 if (line == NULL) {31 fprintf (stderr, "ERROR: queue %s is empty\n", argv[1]);32 return (FALSE);40 if (Key == -1) { 41 line = PopQueue (queue); 42 } else { 43 line = PopQueueMatch (queue, Key, Value); 33 44 } 34 45 35 if (var == (char *) NULL) { 36 fprintf (stderr, "%s\n", line); 46 if (var == NULL) { 47 if (line == NULL) { 48 fprintf (stderr, "queue %s is empty or match not found\n", argv[1]); 49 return (FALSE); 50 } else { 51 fprintf (stderr, "%s\n", line); 52 return (TRUE); 53 } 54 } 55 56 if (line == NULL) { 57 set_str_variable (var, "NULL"); 37 58 } else { 38 set_str_variable ( argv[2], line);59 set_str_variable (var, line); 39 60 } 40 61 -
trunk/Ohana/src/opihi/include/psched.h
r4763 r6249 73 73 74 74 struct timeval last; 75 76 int Nsuccess; 77 int Nfailure; 78 int Ntimeout; 79 75 80 } Task; 76 81 -
trunk/Ohana/src/opihi/lib.data/queues.c
r4704 r6249 281 281 queue[0].Nlines --; 282 282 283 /* shrink queue allocation if small enough */ 283 284 NLINES_2 = MAX (16, queue[0].NLINES / 2); 284 285 if (queue[0].Nlines < NLINES_2) { … … 289 290 } 290 291 292 /* pop the first entry which for which the key matches */ 293 char *PopQueueMatch (Queue *queue, int Key, char *value) { 294 295 int i, choice, NLINES_2; 296 char *line, *test; 297 298 if (queue[0].Nlines == 0) return (NULL); 299 300 /* find the matching key */ 301 choice = -1; 302 for (i = 0; (i < queue[0].Nlines) && (choice == -1); i++) { 303 test = ChooseKey (queue[0].lines[i], Key); 304 if (test == NULL) continue; 305 if (strcmp (value, test)) continue; 306 choice = i; 307 } 308 if (choice == -1) return NULL; 309 310 line = queue[0].lines[choice]; 311 312 for (i = choice; i < queue[0].Nlines - 1; i++) { 313 queue[0].lines[i] = queue[0].lines[i+1]; 314 } 315 queue[0].Nlines --; 316 317 /* shrink queue allocation if small enough */ 318 NLINES_2 = MAX (16, queue[0].NLINES / 2); 319 if (queue[0].Nlines < NLINES_2) { 320 queue[0].NLINES = NLINES_2; 321 REALLOCATE (queue[0].lines, char *, queue[0].NLINES); 322 } 323 return (line); 324 } 325 291 326 int PrintQueue (FILE *f, Queue *queue) { 292 327 -
trunk/Ohana/src/opihi/lib.shell/check_stack.c
r4689 r6249 14 14 stack[i].Float = strtod (stack[i].name, &c); 15 15 if (c == stack[i].name + strlen (stack[i].name)) { 16 # if (0) 17 if (Nstack == 1) { 18 stack[i].type = 'W'; 19 } else { 20 stack[i].ptr = &(stack[i].Float); 21 stack[i].type = 'S'; 22 } 23 # endif 16 24 stack[i].ptr = &(stack[i].Float); 17 25 stack[i].type = 'S'; -
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r4763 r6249 6 6 Macro *macro; 7 7 int i, status; 8 char varname[64]; 8 9 9 10 /** test all jobs: ready to test? finished? **/ … … 30 31 PushNamedQueue ("stdout", job[0].stdout.buffer); 31 32 PushNamedQueue ("stderr", job[0].stderr.buffer); 33 /* set taskarg variables */ 34 for (i = 0; i < job[0].argc; i++) { 35 sprintf (varname, "taskarg:%d", i); 36 set_str_variable (varname, job[0].argv[i]); 37 } 38 set_int_variable ("taskarg:n", job[0].argc); 39 32 40 /* XXX this will break on 0 values in output streams */ 33 41 /* perhaps define PushNamedQueueBuffer */ … … 43 51 PushNamedQueue ("stdout", job[0].stdout.buffer); 44 52 PushNamedQueue ("stderr", job[0].stderr.buffer); 53 /* set taskarg variables */ 54 for (i = 0; i < job[0].argc; i++) { 55 sprintf (varname, "taskarg:%d", i); 56 set_str_variable (varname, job[0].argv[i]); 57 } 58 set_int_variable ("taskarg:n", job[0].argc); 59 60 /* update the exit status counters */ 61 if (job[0].exit_status) { 62 job[0].task[0].Nfailure ++; 63 } else { 64 job[0].task[0].Nsuccess ++; 65 } 66 45 67 /* run corresponding task[0].exit macro, if it exists */ 46 68 macro = job[0].task[0].defexit; … … 68 90 if (GetTaskTimer(job[0].start) < job[0].task[0].timeout_period) continue; 69 91 if (VerboseMode()) fprintf (stderr, "timeout on %s\n", job[0].task[0].name); 92 93 /* update the timeout counter */ 94 job[0].task[0].Ntimeout ++; 95 70 96 if (!KillLocalJob (job)) { 71 97 job[0].state = JOB_HUNG; … … 73 99 continue; 74 100 } 101 102 /* set taskarg variables */ 103 for (i = 0; i < job[0].argc; i++) { 104 sprintf (varname, "taskarg:%d", i); 105 set_str_variable (varname, job[0].argv[i]); 106 } 107 set_int_variable ("taskarg:n", job[0].argc); 108 109 75 110 /* run task[0].timeout macro, if it exists */ 76 111 if (job[0].task[0].timeout != NULL) { -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r4705 r6249 229 229 /* init task timer (is reset by 'run') */ 230 230 gettimeofday (&NewTask[0].last, (void *) NULL); 231 NewTask[0].Nmax = 0; /* default value means 'no limit' */ 232 231 233 NewTask[0].Njobs = 0; 232 NewTask[0].Nmax = 0; /* default value means 'no limit' */ 233 234 NewTask[0].Nsuccess = 0; 235 NewTask[0].Nfailure = 0; 236 NewTask[0].Ntimeout = 0; 234 237 return (NewTask); 235 238 } -
trunk/Ohana/src/opihi/pantasks/task_periods.c
r4693 r6249 42 42 task = GetNewTask (); 43 43 if (task == NULL) { 44 fprintf (stderr, "ERROR: not defining or running a task\n"); 45 return (FALSE); 44 task = GetActiveTask (); 45 if (task == NULL) { 46 fprintf (stderr, "ERROR: not defining or running a task\n"); 47 return (FALSE); 48 } 46 49 } 47 50
Note:
See TracChangeset
for help on using the changeset viewer.
