[BusyBox] rdate: Use read and not safe_read [PATCH]

Shaun Jackman sjackman at gmail.com
Sat Mar 19 19:15:32 UTC 2005


I'm not sure why safe_read was used, since the intention was for the
alarm to interrupt the read, which safe_read prevents. I found the 10
second timeout too long and reduced it to 5, but this is personal
preference.

Cheers,
Shaun

2005-03-19  Shaun Jackman  <sjackman at gmail.com>

	* util-linux/rdate.c (askremotedate): Reduce the alarm timeout
	from 10 seconds to 5 seconds. Use read and not safe_read so that
	the alarm will interrupt the read. Cancel the alarm once the time
	has been received.

diff -ur busybox-1.00.orig/util-linux/rdate.c busybox-1.00/util-linux/rdate.c
--- busybox-1.00.orig/util-linux/rdate.c	2004-01-18 10:18:33.000000000 -0800
+++ busybox-1.00/util-linux/rdate.c	2005-03-17 11:28:50.000000000 -0800
@@ -54,13 +54,15 @@
 	s_in.sin_port = bb_lookup_port("time", "tcp", 37);
 
 	/* Add a timeout for dead or non accessable servers */
-	alarm(10);
+	alarm(5);
 	signal(SIGALRM, socket_timeout);
 
 	fd = xconnect(&s_in);
 
-	if (safe_read(fd, (void *)&nett, 4) != 4)    /* read time from server */
+	if (read(fd, (void *)&nett, 4) != 4)    /* read time from server */
 		bb_error_msg_and_die("%s did not send the complete time", host);
+	/* Cancel the timeout. */
+	alarm(0);
 
 	close(fd);



More information about the busybox mailing list