소스 검색

[job] Allow job_progress() to return an ongoing job status code, if known

Some background jobs have a meaningful ongoing status code (e.g. the
current link status for a job waiting for a network link to come up).
Allow this to be exposed via the job_progress() method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 년 전
부모
커밋
5674a3c087
3개의 변경된 파일20개의 추가작업 그리고 9개의 파일을 삭제
  1. 5
    2
      src/core/downloader.c
  2. 12
    4
      src/core/job.c
  3. 3
    3
      src/include/ipxe/job.h

+ 5
- 2
src/core/downloader.c 파일 보기

@@ -131,9 +131,10 @@ static int downloader_ensure_size ( struct downloader *downloader,
131 131
  *
132 132
  * @v downloader	Downloader
133 133
  * @v progress		Progress report to fill in
134
+ * @ret ongoing_rc	Ongoing job status code (if known)
134 135
  */
135
-static void downloader_progress ( struct downloader *downloader,
136
-				  struct job_progress *progress ) {
136
+static int downloader_progress ( struct downloader *downloader,
137
+				 struct job_progress *progress ) {
137 138
 
138 139
 	/* This is not entirely accurate, since downloaded data may
139 140
 	 * arrive out of order (e.g. with multicast protocols), but
@@ -141,6 +142,8 @@ static void downloader_progress ( struct downloader *downloader,
141 142
 	 */
142 143
 	progress->completed = downloader->pos;
143 144
 	progress->total = downloader->image->len;
145
+
146
+	return 0;
144 147
 }
145 148
 
146 149
 /****************************************************************************

+ 12
- 4
src/core/job.c 파일 보기

@@ -34,22 +34,30 @@ FILE_LICENCE ( GPL2_OR_LATER );
34 34
  *
35 35
  * @v intf		Object interface
36 36
  * @v progress		Progress data to fill in
37
+ * @ret ongoing_rc	Ongoing job status code (if known)
37 38
  */
38
-void job_progress ( struct interface *intf, struct job_progress *progress ) {
39
+int job_progress ( struct interface *intf, struct job_progress *progress ) {
39 40
 	struct interface *dest;
40 41
 	job_progress_TYPE ( void * ) *op =
41 42
 		intf_get_dest_op ( intf, job_progress, &dest );
42 43
 	void *object = intf_object ( dest );
44
+	int ongoing_rc;
43 45
 
44 46
 	DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " job_progress\n",
45 47
 	       INTF_INTF_DBG ( intf, dest ) );
46 48
 
49
+	/* Initialise progress to zero */
50
+	memset ( progress, 0, sizeof ( *progress ) );
51
+
47 52
 	if ( op ) {
48
-		op ( object, progress );
53
+		ongoing_rc = op ( object, progress );
49 54
 	} else {
50
-		/* Default is to mark progress as zero */
51
-		memset ( progress, 0, sizeof ( *progress ) );
55
+		/* Default is to leave progress as zero and have no
56
+		 * known return status code.
57
+		 */
58
+		ongoing_rc = 0;
52 59
 	}
53 60
 
54 61
 	intf_put ( dest );
62
+	return ongoing_rc;
55 63
 }

+ 3
- 3
src/include/ipxe/job.h 파일 보기

@@ -30,9 +30,9 @@ struct job_progress {
30 30
 	unsigned long total;
31 31
 };
32 32
 
33
-extern void job_progress ( struct interface *intf,
34
-			   struct job_progress *progress );
33
+extern int job_progress ( struct interface *intf,
34
+			  struct job_progress *progress );
35 35
 #define job_progress_TYPE( object_type ) \
36
-	typeof ( void ( object_type, struct job_progress *progress ) )
36
+	typeof ( int ( object_type, struct job_progress *progress ) )
37 37
 
38 38
 #endif /* _IPXE_JOB_H */

Loading…
취소
저장