Bladeren bron

[ui] Add progress dots while waiting on any foreground job

Print one dot per second while waiting in monojob.c (e.g. for DHCP,
for file downloads, etc.), to inform user that the system has not
locked up.

Patch contributed by Andrew Schran <aschran@google.com>, minor
modification by me.
tags/v0.9.4
Michael Brown 17 jaren geleden
bovenliggende
commit
702e0be44e
1 gewijzigde bestanden met toevoegingen van 10 en 3 verwijderingen
  1. 10
    3
      src/core/monojob.c

+ 10
- 3
src/core/monojob.c Bestand weergeven

24
 #include <gpxe/keys.h>
24
 #include <gpxe/keys.h>
25
 #include <gpxe/job.h>
25
 #include <gpxe/job.h>
26
 #include <gpxe/monojob.h>
26
 #include <gpxe/monojob.h>
27
+#include <gpxe/timer.h>
27
 
28
 
28
 /** @file
29
 /** @file
29
  *
30
  *
62
 int monojob_wait ( const char *string ) {
63
 int monojob_wait ( const char *string ) {
63
 	int key;
64
 	int key;
64
 	int rc;
65
 	int rc;
66
+	tick_t last_progress_dot;
65
 
67
 
66
-	printf ( "%s... ", string );
68
+	printf ( "%s.", string );
67
 	monojob_rc = -EINPROGRESS;
69
 	monojob_rc = -EINPROGRESS;
70
+	last_progress_dot = currticks();
68
 	while ( monojob_rc == -EINPROGRESS ) {
71
 	while ( monojob_rc == -EINPROGRESS ) {
69
 		step();
72
 		step();
70
 		if ( iskey() ) {
73
 		if ( iskey() ) {
78
 				break;
81
 				break;
79
 			}
82
 			}
80
 		}
83
 		}
84
+		if ( ( currticks() - last_progress_dot ) > TICKS_PER_SEC ) {
85
+			printf ( "." );
86
+			last_progress_dot = currticks();
87
+		}
81
 	}
88
 	}
82
 	rc = monojob_rc;
89
 	rc = monojob_rc;
83
 
90
 
84
 done:
91
 done:
85
 	if ( rc ) {
92
 	if ( rc ) {
86
-		printf ( "%s\n", strerror ( rc ) );
93
+		printf ( " %s\n", strerror ( rc ) );
87
 	} else {
94
 	} else {
88
-		printf ( "ok\n" );
95
+		printf ( " ok\n" );
89
 	}
96
 	}
90
 	return rc;
97
 	return rc;
91
 }
98
 }

Laden…
Annuleren
Opslaan