--- bad/gram_client_tools/source/globusrun.c Mon Jul 28 20:54:27 2003 +++ fix/gram_client_tools/source/globusrun.c Mon Feb 2 16:44:35 2004 @@ -1398,25 +1398,29 @@ globus_mutex_lock(&monitor.mutex); - /* Don't need to wait for state change for job to be submitted or killed - * if that's already happened or if we aren't doing any file staging in - * batch mode + /* If we're running in batch mode and don't need to allow for GASS reads, then we + * don't have to wait for any job state changes */ - if((options & (GLOBUSRUN_ARG_BATCH|GLOBUSRUN_ARG_ALLOW_READS)) && - (monitor.job_state != 0 && - monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_UNSUBMITTED && - monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_STAGE_IN)) - { - monitor.done = GLOBUS_TRUE; - } - else if (GLOBUSRUN_ARG_BATCH == - (options & (GLOBUSRUN_ARG_BATCH|GLOBUSRUN_ARG_ALLOW_READS))) + if ((options & (GLOBUSRUN_ARG_BATCH | GLOBUSRUN_ARG_ALLOW_READS)) == + GLOBUSRUN_ARG_BATCH) { monitor.done = GLOBUS_TRUE; } while(!monitor.done) { + /* If we're running in batch mode and need to allow for GASS reads + * we have to wait until the job is submitted and has finished staging in + */ + if((options & GLOBUSRUN_ARG_BATCH) && (options & GLOBUSRUN_ARG_ALLOW_READS) && + (monitor.job_state != 0 && + monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_UNSUBMITTED && + monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_STAGE_IN)) + { + monitor.done = GLOBUS_TRUE; + continue; + } + globus_cond_wait(&monitor.cond, &monitor.mutex); if(globus_l_globusrun_ctrlc && (!globus_l_globusrun_ctrlc_handled)) { @@ -1428,23 +1432,27 @@ globus_gram_client_job_cancel(monitor.job_contact); globus_l_globusrun_ctrlc_handled = GLOBUS_TRUE; } - if((options & GLOBUSRUN_ARG_BATCH) && - (monitor.job_state != 0 && - monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_UNSUBMITTED && - monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_STAGE_IN)) - { - monitor.done = GLOBUS_TRUE; - } } globus_mutex_unlock(&monitor.mutex); - if(send_commit == GLOBUS_TRUE) + /* If we're using two phase commits then we need to send commit end + * signal if the job is DONE + */ + err = GLOBUS_SUCCESS; + if (monitor.job_state == GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE) { - err = globus_gram_client_job_signal(monitor.job_contact, - GLOBUS_GRAM_PROTOCOL_JOB_SIGNAL_COMMIT_END, + if(send_commit == GLOBUS_TRUE) + { + err = globus_gram_client_job_signal(monitor.job_contact, + GLOBUS_GRAM_PROTOCOL_JOB_SIGNAL_COMMIT_END, "commit", &tmp1, &tmp2); + } + } + else + { + err = monitor.failure_code; } if (options & GLOBUSRUN_ARG_BATCH) @@ -1462,11 +1470,6 @@ globus_mutex_destroy(&monitor.mutex); globus_cond_destroy(&monitor.cond); - if(monitor.job_state != GLOBUS_GRAM_PROTOCOL_JOB_STATE_DONE) - { - err = monitor.failure_code; - } - if((err == GLOBUS_GRAM_PROTOCOL_ERROR_DRYRUN) && (options & GLOBUSRUN_ARG_DRYRUN)) {