http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491540
When "-vv" is specified, rdate now displays a dot each time it tries
to send a packet to the NTP server. This is needed to implement
cancelation of time synchronisation in the debian-installer.
The attached patch will allow rdate to display a line with a single dot
('.') on stderr each time an attempt to contact the NTP server is made.
This is only made when "-vv" has been given on the command-line.
This patch would allow us to implement cancelable progress during the
clock-setup step of the debian-installer.
Jérémy Bobbio <lunar@debian.org> Sun, 20 Jul 2008 11:47:41 +0200
diff -up a/src/rdate.c b/src/rdate.c
--- a/src/rdate.c 2009-05-27 11:44:11.000000000 +1000
+++ b/src/rdate.c 2009-05-27 11:53:47.000000000 +1000
@@ -70,7 +70,7 @@ static const char rcsid[] = "$OpenBSD: r
#endif
void rfc868time_client (const char *, int, struct timeval *, struct timeval *, int, int, int);
-void ntp_client (const char *, int, struct timeval *, struct timeval *, int, int);
+void ntp_client (const char *, int, struct timeval *, struct timeval *, int, int, int);
extern char *__progname;
@@ -157,7 +157,7 @@ main(int argc, char **argv)
hname = argv[optind];
if (ntp)
- ntp_client(hname, family, &new, &adjust, corrleaps, port);
+ ntp_client(hname, family, &new, &adjust, corrleaps, port, verbose);
else
rfc868time_client(hname, family, &new, &adjust, corrleaps, useudp, port);
diff -up a/src/ntp.c b/src/ntp.c
--- a/src/ntp.c 2009-05-27 11:44:11.000000000 +1000
+++ b/src/ntp.c 2009-05-27 11:53:47.000000000 +1000
@@ -110,8 +110,8 @@ struct ntp_data {
u_int64_t xmitck;
};
-void ntp_client(const char *, int, struct timeval *, struct timeval *, int, int);
-int sync_ntp(int, const struct sockaddr *, double *, double *);
+void ntp_client(const char *, int, struct timeval *, struct timeval *, int, int, int);
+int sync_ntp(int, const struct sockaddr *, double *, double *, int);
int write_packet(int, struct ntp_data *);
int read_packet(int, struct ntp_data *, double *, double *);
void unpack_ntp(struct ntp_data *, u_char *);
@@ -126,7 +126,7 @@ int corrleaps;
void
ntp_client(const char *hostname, int family, struct timeval *new,
- struct timeval *adjust, int leapflag, int port)
+ struct timeval *adjust, int leapflag, int port, int verbose)
{
struct addrinfo hints, *res0, *res;
double offset, error;
@@ -155,7 +155,7 @@ ntp_client(const char *hostname, int fam
((struct sockaddr_in*)res->ai_addr)->sin_port = htons(port);
}
- ret = sync_ntp(s, res->ai_addr, &offset, &error);
+ ret = sync_ntp(s, res->ai_addr, &offset, &error, verbose);
if (ret < 0) {
#ifdef DEBUG
fprintf(stderr, "try the next address\n");
@@ -181,7 +181,8 @@ ntp_client(const char *hostname, int fam
}
int
-sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error)
+sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error,
+ int verbose)
{
int attempts = 0, accepts = 0, rejects = 0;
int delay = MAX_DELAY, ret;
@@ -200,6 +201,10 @@ sync_ntp(int fd, const struct sockaddr *
}
while (accepts < MAX_QUERIES && attempts < 2 * MAX_QUERIES) {
+ if (verbose >= 2) {
+ fprintf(stderr, ".\n");
+ fflush(stderr);
+ }
memset(&data, 0, sizeof(data));
if (current_time(JAN_1970) > deadline) {