Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Sep 2001 02:04:40 +0200 (CEST)
From:      Arne.Juul@fast.no
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Tor.Egge@fast.no, mharo@FreeBSD.org, arnej@pvv.ntnu.no
Subject:   ports/30613: ttcp should print statistics on stderr
Message-ID:  <200109160004.f8G04eK30226@guinness.trondheim.fast.no>

next in thread | raw e-mail | index | archive | help

>Number:         30613
>Category:       ports
>Synopsis:       ttcp should print statistics on stderr
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 16 11:50:04 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Arne H Juul
>Release:        FreeBSD 4.3-RELEASE i386
>Organization:
Fast Search & Transfer
>Environment:
System: FreeBSD guinness.trondheim.fast.no 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Mon Apr 23 17:05:17 CEST 2001 arnej@guinness.trondheim.fast.no:/usr/obj/usr/src/sys/GUINNESS_PXE i386

>Description:
	ttcp is a nice tool in the default mode for transferring data
	between machines in an efficient way.  However, ttcp has the
	annoying habit of printing some of its statistics on stdout.
	Here are some patches I've been using for a long time
	(see also ftp://ftp.ntnu.no/pub/unix/utils/ttcp-1.13.tar.Z)
	that fix this annoyance, as an extra bonus there's a
	portability fix and a patch that avoids some odd corner
	cases of signed modulo arithmetic.

	Please add these to the ttcp package!

>How-To-Repeat:
	$ ttcp -r > foo &
	$ ttcp -t localhost < /dev/null
	$ ls -l foo
	notice that foo isn't zero bytes as it should be.
>Fix:
	add these patches:

--- ttcp.c.orig	Sun Sep 16 00:31:43 2001
+++ ttcp.c	Sun Sep 16 00:35:02 2001
@@ -253,6 +253,7 @@
 #endif /* cray */
 		}
 		sinhim.sin_port = htons(port);
+		sinme.sin_family = AF_INET;     /* Solaris needs this */
 		sinme.sin_port = 0;		/* free choice */
 	} else {
 		/* rcvr */
--- ttcp.c.orig	Sun Sep 16 00:36:49 2001
+++ ttcp.c	Sun Sep 16 00:37:34 2001
@@ -271,26 +271,26 @@
 		buf +=(bufalign - ((int)buf % bufalign) + bufoffset) % bufalign;
 
 	if (trans) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 	    "ttcp-t: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
 		buflen, nbuf, bufalign, bufoffset, port);
  	    if (sockbufsize)
- 		fprintf(stdout, ", sockbufsize=%d", sockbufsize);
- 	    fprintf(stdout, "  %s  -> %s\n", udp?"udp":"tcp", host);
+ 		fprintf(stderr, ", sockbufsize=%d", sockbufsize);
+ 	    fprintf(stderr, "  %s  -> %s\n", udp?"udp":"tcp", host);
 	} else {
-	    fprintf(stdout,
+	    fprintf(stderr,
  	    "ttcp-r: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
  		buflen, nbuf, bufalign, bufoffset, port);
  	    if (sockbufsize)
- 		fprintf(stdout, ", sockbufsize=%d", sockbufsize);
- 	    fprintf(stdout, "  %s\n", udp?"udp":"tcp");
+ 		fprintf(stderr, ", sockbufsize=%d", sockbufsize);
+ 	    fprintf(stderr, "  %s\n", udp?"udp":"tcp");
 	}
 
 	if ((fd = socket(AF_INET, udp?SOCK_DGRAM:SOCK_STREAM, 0)) < 0)
 		err("socket");
 	mes("socket");
 
-	if (bind(fd, (struct sockaddr*)&sinme, sizeof(sinme)) < 0)
+	if (bind(fd, (struct sockaddr *) &sinme, sizeof(sinme)) < 0)
 		err("bind");
 
 #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
@@ -417,25 +417,25 @@
 	}
 	if( cput <= 0.0 )  cput = 0.001;
 	if( realt <= 0.0 )  realt = 0.001;
-	fprintf(stdout,
+	fprintf(stderr,
 		"ttcp%s: %.0f bytes in %.2f real seconds = %s/sec +++\n",
 		trans?"-t":"-r",
 		nbytes, realt, outfmt(nbytes/realt));
 	if (verbose) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 		"ttcp%s: %.0f bytes in %.2f CPU seconds = %s/cpu sec\n",
 		trans?"-t":"-r",
 		nbytes, cput, outfmt(nbytes/cput));
 	}
-	fprintf(stdout,
+	fprintf(stderr,
 		"ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
 		trans?"-t":"-r",
 		numCalls,
 		1024.0 * realt/((double)numCalls),
 		((double)numCalls)/realt);
-	fprintf(stdout,"ttcp%s: %s\n", trans?"-t":"-r", stats);
+	fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", stats);
 	if (verbose) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 		"ttcp%s: buffer address %#x\n",
 		trans?"-t":"-r",
 		buf);
--- ttcp.c.orig	Sun Sep 16 00:38:12 2001
+++ ttcp.c	Sun Sep 16 00:39:44 2001
@@ -268,7 +268,9 @@
 	if ( (buf = (char *)malloc(buflen+bufalign)) == (char *)NULL)
 		err("malloc");
 	if (bufalign != 0)
-		buf +=(bufalign - ((int)buf % bufalign) + bufoffset) % bufalign;
+		buf += (bufalign
+			-((unsigned long)buf % bufalign)
+			+ bufoffset) % bufalign;
 
 	if (trans) {
 	    fprintf(stderr,
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109160004.f8G04eK30226>