Package: rdate-udeb
Version: 1.1.3-1
Severity: wishlist
Tags: d-i

Hi!

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. [1]

The patch is really simple and would worth an inclusion in Lenny.

[1] See Message-ID <[EMAIL PROTECTED]> on [EMAIL PROTECTED]

Cheers,
-- 
Jérémy Bobbio                        .''`. 
[EMAIL PROTECTED]                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
diff -u rdate-1.1.3/src/rdate.c rdate-1.1.3/src/rdate.c
--- rdate-1.1.3/src/rdate.c
+++ rdate-1.1.3/src/rdate.c
@@ -70,7 +70,7 @@
 #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 @@
 	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 -u rdate-1.1.3/src/ntp.c rdate-1.1.3/src/ntp.c
--- rdate-1.1.3/src/ntp.c
+++ rdate-1.1.3/src/ntp.c
@@ -110,8 +110,8 @@
 	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 @@
 
 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 @@
 			((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 @@
 }
 
 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 @@
 	}
 
 	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) {
diff -u rdate-1.1.3/debian/changelog rdate-1.1.3/debian/changelog
--- rdate-1.1.3/debian/changelog
+++ rdate-1.1.3/debian/changelog
@@ -1,3 +1,11 @@
+rdate (1:1.1.3-2~~lunar1) UNRELEASED; urgency=low
+
+  * 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.
+
+ -- J�r�my Bobbio <[EMAIL PROTECTED]>  Wed, 12 Mar 2008 08:04:06 +0100
+
 rdate (1:1.1.3-1) unstable; urgency=low
 
   * New upstream release

Attachment: signature.asc
Description: Digital signature

Reply via email to