[monojob] Report ongoing job status as overall return status on timeout
If a job times out then use the most recent ongoing error status reported via job_progress() (if available) as the overall return status. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
d1be9f4acc
commit
dc7a023715
@ -69,6 +69,7 @@ int monojob_wait ( const char *string, unsigned long timeout ) {
|
|||||||
unsigned long total;
|
unsigned long total;
|
||||||
unsigned int percentage;
|
unsigned int percentage;
|
||||||
int shown_percentage = 0;
|
int shown_percentage = 0;
|
||||||
|
int ongoing_rc;
|
||||||
int key;
|
int key;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -97,10 +98,13 @@ int monojob_wait ( const char *string, unsigned long timeout ) {
|
|||||||
last_keycheck = now;
|
last_keycheck = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Monitor progress */
|
||||||
|
ongoing_rc = job_progress ( &monojob, &progress );
|
||||||
|
|
||||||
/* Check for timeout, if applicable */
|
/* Check for timeout, if applicable */
|
||||||
elapsed = ( now - start );
|
elapsed = ( now - start );
|
||||||
if ( timeout && ( elapsed >= timeout ) ) {
|
if ( timeout && ( elapsed >= timeout ) ) {
|
||||||
monojob_rc = -ETIMEDOUT;
|
monojob_rc = ( ongoing_rc ? ongoing_rc : -ETIMEDOUT );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +113,6 @@ int monojob_wait ( const char *string, unsigned long timeout ) {
|
|||||||
if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
|
if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
|
||||||
if ( shown_percentage )
|
if ( shown_percentage )
|
||||||
printf ( "\b\b\b\b \b\b\b\b" );
|
printf ( "\b\b\b\b \b\b\b\b" );
|
||||||
job_progress ( &monojob, &progress );
|
|
||||||
/* Normalise progress figures to avoid overflow */
|
/* Normalise progress figures to avoid overflow */
|
||||||
completed = ( progress.completed / 128 );
|
completed = ( progress.completed / 128 );
|
||||||
total = ( progress.total / 128 );
|
total = ( progress.total / 128 );
|
||||||
|
Reference in New Issue
Block a user