Browse Source

[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>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
dc7a023715
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/core/monojob.c

+ 5
- 2
src/core/monojob.c View File

69
 	unsigned long total;
69
 	unsigned long total;
70
 	unsigned int percentage;
70
 	unsigned int percentage;
71
 	int shown_percentage = 0;
71
 	int shown_percentage = 0;
72
+	int ongoing_rc;
72
 	int key;
73
 	int key;
73
 	int rc;
74
 	int rc;
74
 
75
 
97
 			last_keycheck = now;
98
 			last_keycheck = now;
98
 		}
99
 		}
99
 
100
 
101
+		/* Monitor progress */
102
+		ongoing_rc = job_progress ( &monojob, &progress );
103
+
100
 		/* Check for timeout, if applicable */
104
 		/* Check for timeout, if applicable */
101
 		elapsed = ( now - start );
105
 		elapsed = ( now - start );
102
 		if ( timeout && ( elapsed >= timeout ) ) {
106
 		if ( timeout && ( elapsed >= timeout ) ) {
103
-			monojob_rc = -ETIMEDOUT;
107
+			monojob_rc = ( ongoing_rc ? ongoing_rc : -ETIMEDOUT );
104
 			break;
108
 			break;
105
 		}
109
 		}
106
 
110
 
109
 		if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
113
 		if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
110
 			if ( shown_percentage )
114
 			if ( shown_percentage )
111
 				printf ( "\b\b\b\b    \b\b\b\b" );
115
 				printf ( "\b\b\b\b    \b\b\b\b" );
112
-			job_progress ( &monojob, &progress );
113
 			/* Normalise progress figures to avoid overflow */
116
 			/* Normalise progress figures to avoid overflow */
114
 			completed = ( progress.completed / 128 );
117
 			completed = ( progress.completed / 128 );
115
 			total = ( progress.total / 128 );
118
 			total = ( progress.total / 128 );

Loading…
Cancel
Save