~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to dttools/src/batch_job_work_queue.c

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2012-03-30 12:40:01 UTC
  • mfrom: (9.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120330124001-ze0lhxm5uwq2e3mo
Tags: 3.4.2-2
Added patch to handle a missing CFLAGS variable in Python's sysconfig
report (Closes: #661658).

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
 
55
55
void specify_work_queue_task_shared_files(struct work_queue_task *t, const char *input_files, const char *output_files)
56
56
{
57
 
        char *f, *p, *files;
58
 
 
59
57
        if(input_files) {
60
 
                files = strdup(input_files);
61
 
                f = strtok(files, " \t,");
62
 
                while(f) {
63
 
                        char fname[WORK_QUEUE_LINE_MAX];
64
 
                        p = strchr(f, '=');
 
58
                char *files = strdup(input_files);
 
59
                char *file = strtok(files, " \t,");
 
60
                while(file) {
 
61
                        file = strdup(file);
 
62
                        char *p = strchr(file, '=');
65
63
                        if(p) {
66
64
                                *p = 0;
67
65
                        }
68
66
 
69
 
                        if(f[0] != '/') {
70
 
                                char tmp[WORK_QUEUE_LINE_MAX];
71
 
                                getcwd(tmp, WORK_QUEUE_LINE_MAX);
72
 
                                strcat(tmp, "/");
73
 
                                strcat(tmp, f);
74
 
                                string_collapse_path(tmp, fname, 1);
75
 
                        } else {
76
 
                                strcpy(fname, f);
 
67
                        if(file[0] != '/') {
 
68
                                char *cwd = string_getcwd();
 
69
                                char *new = string_format("%s/%s", cwd, file);
 
70
                                free(file);
 
71
                                free(cwd);
 
72
                                file = new;
77
73
                        }
78
74
 
79
75
                        if(p) { 
80
 
                                work_queue_task_specify_file(t, f, p + 1, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE|WORK_QUEUE_THIRDGET);
81
 
                                debug(D_DEBUG, "shared file %s is %s on remote system:", f, p + 1);
 
76
                                work_queue_task_specify_file(t, file, p + 1, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE|WORK_QUEUE_THIRDGET);
 
77
                                debug(D_DEBUG, "shared file %s is %s on remote system:", file, p + 1);
82
78
                                *p = '=';
83
79
                        } else {
84
 
                                work_queue_task_specify_file(t, fname, fname, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE|WORK_QUEUE_THIRDGET);
 
80
                                work_queue_task_specify_file(t, file, file, WORK_QUEUE_INPUT, WORK_QUEUE_CACHE|WORK_QUEUE_THIRDGET);
85
81
                        }
86
 
                        f = strtok(0, " \t,");
 
82
                        free(file);
 
83
                        file = strtok(0, " \t,");
87
84
                }
88
85
                free(files);
89
86
        }
90
87
 
91
88
        if(output_files) {
92
 
                files = strdup(output_files);
93
 
                f = strtok(files, " \t,");
94
 
                while(f) {
95
 
                        char fname[WORK_QUEUE_LINE_MAX];
96
 
                        p = strchr(f, '=');
 
89
                char *files = strdup(output_files);
 
90
                char *file = strtok(files, " \t,");
 
91
                while(file) {
 
92
                        file = strdup(file);
 
93
                        char *p = strchr(file, '=');
97
94
                        if(p) {
98
95
                                *p = 0;
99
96
                        }
100
97
 
101
 
                        if(f[0] != '/') {
102
 
                                char tmp[WORK_QUEUE_LINE_MAX];
103
 
                                getcwd(tmp, WORK_QUEUE_LINE_MAX);
104
 
                                strcat(tmp, "/");
105
 
                                strcat(tmp, f);
106
 
                                string_collapse_path(tmp, fname, 1);
107
 
                        } else {
108
 
                                strcpy(fname, f);
 
98
                        if(file[0] != '/') {
 
99
                                char *cwd = string_getcwd();
 
100
                                char *new = string_format("%s/%s", cwd, file);
 
101
                                free(file);
 
102
                                free(cwd);
 
103
                                file = new;
109
104
                        }
110
105
 
111
106
                        if(p) { 
112
 
                                work_queue_task_specify_file(t, fname, p + 1, WORK_QUEUE_OUTPUT, WORK_QUEUE_THIRDPUT);
113
 
                                debug(D_DEBUG, "shared file %s is %s on remote system:", f, p + 1);
 
107
                                work_queue_task_specify_file(t, file, p + 1, WORK_QUEUE_OUTPUT, WORK_QUEUE_THIRDPUT);
 
108
                                debug(D_DEBUG, "shared file %s is %s on remote system:", file, p + 1);
114
109
                                *p = '=';
115
110
                        } else {
116
 
                                work_queue_task_specify_file(t, fname, fname, WORK_QUEUE_OUTPUT, WORK_QUEUE_THIRDPUT);
 
111
                                work_queue_task_specify_file(t, file, file, WORK_QUEUE_OUTPUT, WORK_QUEUE_THIRDPUT);
117
112
                        }
118
 
                        f = strtok(0, " \t,");
 
113
                        free(file);
 
114
                        file = strtok(0, " \t,");
119
115
                }
120
116
                free(files);
121
117
        }
123
119
 
124
120
batch_job_id_t batch_job_submit_work_queue(struct batch_queue *q, const char *cmd, const char *args, const char *infile, const char *outfile, const char *errfile, const char *extra_input_files, const char *extra_output_files)
125
121
{
126
 
        struct work_queue_task *t;
127
 
        char *full_command;
128
 
 
129
 
        if(infile)
130
 
                full_command = (char *) malloc((strlen(cmd) + strlen(args) + strlen(infile) + 5) * sizeof(char));
131
 
        else
132
 
                full_command = (char *) malloc((strlen(cmd) + strlen(args) + 2) * sizeof(char));
133
 
 
134
 
        if(!full_command) {
135
 
                debug(D_DEBUG, "couldn't create new work_queue task: out of memory\n");
136
 
                return -1;
 
122
        char *command = string_format("%s %s", cmd, args);
 
123
        if(infile) {
 
124
                char *new = string_format("%s <%s", command, infile);
 
125
                free(command);
 
126
                command = new;
137
127
        }
138
128
 
139
 
        if(infile)
140
 
                sprintf(full_command, "%s %s < %s", cmd, args, infile);
141
 
        else
142
 
                sprintf(full_command, "%s %s", cmd, args);
143
 
 
144
 
        t = work_queue_task_create(full_command);
145
 
 
146
 
        free(full_command);
 
129
        struct work_queue_task *t = work_queue_task_create(command);
 
130
 
 
131
        free(command);
147
132
 
148
133
        if(q->type == BATCH_QUEUE_TYPE_WORK_QUEUE_SHAREDFS) {
149
134
                if(infile)