Changeset 8129
- Timestamp:
- Aug 4, 2006, 2:19:21 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 added
- 7 edited
-
include/pantasks.h (modified) (3 diffs)
-
pantasks/CheckJobs.c (modified) (3 diffs)
-
pantasks/JobOps.c (modified) (2 diffs)
-
pantasks/Makefile (modified) (1 diff)
-
pantasks/TaskOps.c (modified) (4 diffs)
-
pantasks/init.c (modified) (2 diffs)
-
pantasks/task.c (modified) (1 diff)
-
pantasks/task_options.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/pantasks.h
r7960 r8129 41 41 TASK_HOST, 42 42 TASK_COMMAND, 43 TASK_OPTIONS, 43 44 TASK_PERIODS, 44 45 TASK_EXIT, … … 66 67 int argc; 67 68 char **argv; 69 70 int optc; 71 char **optv; 72 68 73 char *host; 69 74 int host_required; … … 112 117 int argc; 113 118 char **argv; 119 120 int optc; 121 char **optv; 122 114 123 Task *task; 115 124 -
trunk/Ohana/src/opihi/pantasks/CheckJobs.c
r7917 r8129 26 26 27 27 case JOB_CRASH: 28 /* run task[0].crash macro, if it exists */ 28 case JOB_EXIT: 29 29 /* push output buffer data to the stdout and stderr queues */ 30 if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);30 /* XXX this will break on 0 values in output streams */ 31 31 PushNamedQueue ("stdout", job[0].stdout.buffer); 32 32 PushNamedQueue ("stderr", job[0].stderr.buffer); 33 33 34 /* set taskarg variables */ 34 35 for (i = 0; i < job[0].argc; i++) { … … 38 39 set_int_variable ("taskarg:n", job[0].argc); 39 40 40 /* XXX this will break on 0 values in output streams */41 /* perhaps define PushNamedQueueBuffer */42 if (job[0].task[0].crash != NULL) {43 exec_loop (job[0].task[0].crash);41 /* set options variables */ 42 for (i = 0; i < job[0].optc; i++) { 43 sprintf (varname, "options:%d", i); 44 set_str_variable (varname, job[0].optv[i]); 44 45 } 45 DeleteJob (job); 46 continue; 47 break; 46 set_int_variable ("options:n", job[0].optc); 48 47 49 case JOB_EXIT: 50 if (VerboseMode()) gprint (GP_LOG, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID); 51 PushNamedQueue ("stdout", job[0].stdout.buffer); 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]); 48 if (status == JOB_CRASH) { 49 /* XXX add an Ncrash element? */ 50 job[0].task[0].Nfailure ++; 51 52 /* run task[0].crash macro, if it exists */ 53 /* perhaps define PushNamedQueueBuffer */ 54 55 if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID); 56 if (job[0].task[0].crash != NULL) { 57 exec_loop (job[0].task[0].crash); 58 } 57 59 } 58 set_int_variable ("taskarg:n", job[0].argc); 60 if (status == JOB_EXIT) { 61 /* update the exit status counters */ 62 if (job[0].exit_status) { 63 job[0].task[0].Nfailure ++; 64 } else { 65 job[0].task[0].Nsuccess ++; 66 } 59 67 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 ++; 68 /* run corresponding task[0].exit macro, if it exists */ 69 if (VerboseMode()) gprint (GP_LOG, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID); 70 macro = job[0].task[0].defexit; 71 for (i = 0; i < job[0].task[0].Nexit; i++) { 72 if (job[0].exit_status == atoi(job[0].task[0].exit[i][0].name)) { 73 macro = job[0].task[0].exit[i]; 74 break; 75 } 76 } 77 if (macro != NULL) exec_loop (macro); 65 78 } 66 79 67 /* run corresponding task[0].exit macro, if it exists */68 macro = job[0].task[0].defexit;69 for (i = 0; i < job[0].task[0].Nexit; i++) {70 if (job[0].exit_status == atoi(job[0].task[0].exit[i][0].name)) {71 macro = job[0].task[0].exit[i];72 break;73 }74 }75 if (macro != NULL) exec_loop (macro);76 80 DeleteJob (job); 77 81 continue; … … 107 111 set_int_variable ("taskarg:n", job[0].argc); 108 112 113 /* set options variables */ 114 for (i = 0; i < job[0].optc; i++) { 115 sprintf (varname, "options:%d", i); 116 set_str_variable (varname, job[0].optv[i]); 117 } 118 set_int_variable ("options:n", job[0].optc); 109 119 110 120 /* run task[0].timeout macro, if it exists */ -
trunk/Ohana/src/opihi/pantasks/JobOps.c
r7917 r8129 103 103 job[0].argv[i] = 0; 104 104 105 /* we need our own copy of task[0].optv: optc is the number of valid opts. */ 106 job[0].optc = task[0].optc; 107 ALLOCATE (job[0].optv, char *, MAX (task[0].optc, 1)); 108 for (i = 0; i < job[0].optc; i++) { 109 job[0].optv[i] = strcreate (task[0].optv[i]); 110 } 111 105 112 /* Other data from the task is needed by the job. We carry a pointer back to the task. Changes to an 106 113 executing task are applied to the existing jobs (exit macros, poll_period, timeout) */ … … 136 143 free (job[0].argv); 137 144 145 for (i = 0; i < job[0].optc; i++) { 146 free (job[0].optv[i]); 147 } 148 free (job[0].optv); 149 138 150 FreeIOBuffer (&job[0].stdout); 139 151 FreeIOBuffer (&job[0].stderr); -
trunk/Ohana/src/opihi/pantasks/Makefile
r7960 r8129 63 63 $(SDIR)/task_periods.$(ARCH).o \ 64 64 $(SDIR)/task_command.$(ARCH).o \ 65 $(SDIR)/task_options.$(ARCH).o \ 65 66 $(SDIR)/version.$(ARCH).o 66 67 -
trunk/Ohana/src/opihi/pantasks/TaskOps.c
r7917 r8129 116 116 gprint (GP_LOG, "\n\n"); 117 117 118 gprint (GP_LOG, "\n options: "); 119 for (i = 0; i < task[0].optc; i++) { 120 gprint (GP_LOG, "%s ", task[0].optv[i]); 121 } 122 gprint (GP_LOG, "\n\n"); 123 118 124 if (task[0].host == NULL) { 119 125 gprint (GP_LOG, " task runs locally\n"); … … 169 175 free (task[0].argv); 170 176 } 177 if (task[0].optv != NULL) { 178 for (i = 0; i < task[0].optc; i++) { 179 free (task[0].optv[i]); 180 } 181 free (task[0].optv); 182 } 171 183 if (task[0].exec != NULL) { 172 184 FreeMacro (task[0].exec); … … 209 221 NewTask[0].argc = 0; 210 222 NewTask[0].argv = NULL; 223 224 NewTask[0].optc = 0; 225 NewTask[0].optv = NULL; 211 226 212 227 NewTask[0].exec = NULL; … … 346 361 if (!strcasecmp (command, "TRANGE")) hash = TASK_TRANGE; 347 362 if (!strcasecmp (command, "COMMAND")) hash = TASK_COMMAND; 363 if (!strcasecmp (command, "OPTIONS")) hash = TASK_OPTIONS; 348 364 if (!strcasecmp (command, "PERIODS")) hash = TASK_PERIODS; 349 365 if (!strcasecmp (command, "TASK.EXIT")) hash = TASK_EXIT; -
trunk/Ohana/src/opihi/pantasks/init.c
r7960 r8129 8 8 int task_macros PROTO((int, char **)); 9 9 int task_command PROTO((int, char **)); 10 int task_options PROTO((int, char **)); 10 11 int task_periods PROTO((int, char **)); 11 12 int run PROTO((int, char **)); … … 27 28 {"task.exec", task_macros, "define pre-exec macro for a task"}, 28 29 {"command", task_command, "define executed command for a task"}, 30 {"options", task_options, "define optional variables associated with the job task"}, 29 31 {"periods", task_periods, "define time scales for a task"}, 30 32 {"run", run, "run the scheduler"}, -
trunk/Ohana/src/opihi/pantasks/task.c
r7960 r8129 95 95 case TASK_EXEC: 96 96 case TASK_COMMAND: 97 case TASK_OPTIONS: 97 98 case TASK_PERIODS: 98 99 status = command (input, &outline, TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
