Subject: net/echoping patch
To: None <tech-pkg@netbsd.org>
From: Jeff Rizzo <riz@NetBSD.org>
List: tech-pkg
Date: 04/20/2006 15:41:01
--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Since net/echoping has 'tech-pkg@NetBSD.org' as a maintainer, and I don't
have time right now to make sure this patch doesn't break anything for
others, I submit for Someone Else to commit this if it seems appropriate.
(I've already submitted it as a bug to the echoping sourceforge site;
hopefully it will get picked up in the next version)

The problem:  if an OS has usleep() (like NetBSD does), the inter-packet
gap is always timed with usleep(wait * 1000000), where wait is
a (double) number of seconds.  However, SUSv3 states that the argument
to usleep() should be less than 1000000, and indeed, on NetBSD the
usleep() fails when wait is >=3D 1.0.   So, I cooked up the following
patch, which makes it behave in a fashion more consistent with the
intent:


--- echoping.c.orig	2006-04-20 15:09:49.000000000 -0700
+++ echoping.c	2006-04-20 15:20:24.000000000 -0700
@@ -655,7 +655,13 @@
       if (i > 1)
 	{
 #ifdef HAVE_USLEEP
-	  usleep (wait * 1000000);
+	  /*
+	   * SUSv3 states that the argument to usleep() shall be less
+	   * than 1000000, so split into two calls if necessary.
+	   */=20
+	  if (wait >=3D 1)
+	  	sleep (wait);
+	  usleep ((wait - (unsigned int)wait) * 1000000);
 #else
 	  sleep (wait);
 #endif


As I said, if someone could double-check me and commit this to pkgsrc,
I'd be grateful...

+j


--nFreZHaLTZJo0R7j
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (NetBSD)

iQCVAwUBREgN/bOuUtxCgar5AQK3QAP+PktL06hgPPcupA2sK1tCKRjRh+CxyCyj
OHKRJKHgAwMl2MUPjtEdbs04uUsjLzuji4Ve8PTU6+vcLswNNgwKS7fHEl9fQXaD
Xk5BgFcOfLQ+ctNCb5Vwi12b273hTdFc4U0/aevIdcIWYPSbUSroy3DKYb7T8ISm
cOWTpKtfR9k=
=/QbH
-----END PGP SIGNATURE-----

--nFreZHaLTZJo0R7j--