incorporate Arne.Juul@fast.no's patches
Submitted by: Arne.Juul@fast.no
This commit is contained in:
parent
3f833214a1
commit
50065a6781
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=48917
@ -1,5 +1,5 @@
|
||||
--- ttcp.c.orig Thu Mar 29 11:41:47 2001
|
||||
+++ ttcp.c Thu Mar 29 11:49:06 2001
|
||||
--- ttcp.c.orig Thu Oct 18 12:26:35 2001
|
||||
+++ ttcp.c Thu Oct 18 12:31:00 2001
|
||||
@@ -55,6 +55,9 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
@ -27,16 +27,55 @@
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
@@ -285,7 +289,7 @@
|
||||
@@ -249,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 */
|
||||
@@ -263,29 +268,31 @@
|
||||
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(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, &sinme, sizeof(sinme)) < 0)
|
||||
+ 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)
|
||||
@@ -326,7 +330,7 @@
|
||||
@@ -326,7 +333,7 @@
|
||||
mes("nodelay");
|
||||
}
|
||||
#endif
|
||||
@ -45,7 +84,7 @@
|
||||
err("connect");
|
||||
mes("connect");
|
||||
} else {
|
||||
@@ -348,11 +352,11 @@
|
||||
@@ -348,11 +355,11 @@
|
||||
}
|
||||
fromlen = sizeof(frominet);
|
||||
domain = AF_INET;
|
||||
@ -59,7 +98,38 @@
|
||||
&peerlen) < 0) {
|
||||
err("getpeername");
|
||||
}
|
||||
@@ -459,6 +463,7 @@
|
||||
@@ -412,25 +419,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);
|
||||
@@ -459,6 +466,7 @@
|
||||
fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", s);
|
||||
}
|
||||
|
||||
@ -67,23 +137,73 @@
|
||||
pattern( cp, cnt )
|
||||
register char *cp;
|
||||
register int cnt;
|
||||
@@ -614,13 +619,13 @@
|
||||
@@ -614,13 +622,13 @@
|
||||
|
||||
case 'U':
|
||||
tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
|
||||
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01ld", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
|
||||
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01ld", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
@@ -684,7 +689,7 @@
|
||||
@@ -642,49 +650,49 @@
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 : (r1->ru_ixrss-r0->ru_ixrss)/t);
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 : (r1->ru_ixrss-r0->ru_ixrss)/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 :
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 :
|
||||
(r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 :
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 :
|
||||
((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) -
|
||||
(r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
- sprintf(outp,"%d", r1->ru_maxrss/2);
|
||||
+ sprintf(outp,"%ld", r1->ru_maxrss/2);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
- sprintf(outp,"%d", r1->ru_majflt-r0->ru_majflt);
|
||||
+ sprintf(outp,"%ld", r1->ru_majflt-r0->ru_majflt);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
- sprintf(outp,"%d", r1->ru_minflt-r0->ru_minflt);
|
||||
+ sprintf(outp,"%ld", r1->ru_minflt-r0->ru_minflt);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
- sprintf(outp,"%d", r1->ru_inblock-r0->ru_inblock);
|
||||
+ sprintf(outp,"%ld", r1->ru_inblock-r0->ru_inblock);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
- sprintf(outp,"%d", r1->ru_oublock-r0->ru_oublock);
|
||||
+ sprintf(outp,"%ld", r1->ru_oublock-r0->ru_oublock);
|
||||
END(outp);
|
||||
break;
|
||||
case 'C':
|
||||
@ -92,7 +212,7 @@
|
||||
r1->ru_nivcsw-r0->ru_nivcsw );
|
||||
END(outp);
|
||||
break;
|
||||
@@ -743,6 +748,7 @@
|
||||
@@ -743,6 +751,7 @@
|
||||
/*
|
||||
* N R E A D
|
||||
*/
|
||||
@ -100,7 +220,7 @@
|
||||
Nread( fd, buf, count )
|
||||
int fd;
|
||||
void *buf;
|
||||
@@ -752,7 +758,7 @@
|
||||
@@ -752,7 +761,7 @@
|
||||
int len = sizeof(from);
|
||||
register int cnt;
|
||||
if( udp ) {
|
||||
@ -109,7 +229,7 @@
|
||||
numCalls++;
|
||||
} else {
|
||||
if( b_flag )
|
||||
@@ -774,6 +780,7 @@
|
||||
@@ -774,6 +783,7 @@
|
||||
/*
|
||||
* N W R I T E
|
||||
*/
|
||||
@ -117,7 +237,7 @@
|
||||
Nwrite( fd, buf, count )
|
||||
int fd;
|
||||
void *buf;
|
||||
@@ -782,7 +789,7 @@
|
||||
@@ -782,7 +792,7 @@
|
||||
register int cnt;
|
||||
if( udp ) {
|
||||
again:
|
||||
@ -126,7 +246,7 @@
|
||||
numCalls++;
|
||||
if( cnt<0 && errno == ENOBUFS ) {
|
||||
delay(18000);
|
||||
@@ -803,7 +810,7 @@
|
||||
@@ -803,7 +813,7 @@
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = us;
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- ttcp.c.orig Thu Mar 29 11:41:47 2001
|
||||
+++ ttcp.c Thu Mar 29 11:49:06 2001
|
||||
--- ttcp.c.orig Thu Oct 18 12:26:35 2001
|
||||
+++ ttcp.c Thu Oct 18 12:31:00 2001
|
||||
@@ -55,6 +55,9 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
@ -27,16 +27,55 @@
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
@@ -285,7 +289,7 @@
|
||||
@@ -249,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 */
|
||||
@@ -263,29 +268,31 @@
|
||||
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(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, &sinme, sizeof(sinme)) < 0)
|
||||
+ 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)
|
||||
@@ -326,7 +330,7 @@
|
||||
@@ -326,7 +333,7 @@
|
||||
mes("nodelay");
|
||||
}
|
||||
#endif
|
||||
@ -45,7 +84,7 @@
|
||||
err("connect");
|
||||
mes("connect");
|
||||
} else {
|
||||
@@ -348,11 +352,11 @@
|
||||
@@ -348,11 +355,11 @@
|
||||
}
|
||||
fromlen = sizeof(frominet);
|
||||
domain = AF_INET;
|
||||
@ -59,7 +98,38 @@
|
||||
&peerlen) < 0) {
|
||||
err("getpeername");
|
||||
}
|
||||
@@ -459,6 +463,7 @@
|
||||
@@ -412,25 +419,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);
|
||||
@@ -459,6 +466,7 @@
|
||||
fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", s);
|
||||
}
|
||||
|
||||
@ -67,23 +137,73 @@
|
||||
pattern( cp, cnt )
|
||||
register char *cp;
|
||||
register int cnt;
|
||||
@@ -614,13 +619,13 @@
|
||||
@@ -614,13 +622,13 @@
|
||||
|
||||
case 'U':
|
||||
tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
|
||||
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01ld", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
|
||||
- sprintf(outp,"%d.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01d", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
+ sprintf(outp,"%ld.%01ld", tdiff.tv_sec, tdiff.tv_usec/100000);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
@@ -684,7 +689,7 @@
|
||||
@@ -642,49 +650,49 @@
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 : (r1->ru_ixrss-r0->ru_ixrss)/t);
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 : (r1->ru_ixrss-r0->ru_ixrss)/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 :
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 :
|
||||
(r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
- sprintf(outp,"%d", t == 0 ? 0 :
|
||||
+ sprintf(outp,"%ld", t == 0 ? 0 :
|
||||
((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) -
|
||||
(r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
- sprintf(outp,"%d", r1->ru_maxrss/2);
|
||||
+ sprintf(outp,"%ld", r1->ru_maxrss/2);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'F':
|
||||
- sprintf(outp,"%d", r1->ru_majflt-r0->ru_majflt);
|
||||
+ sprintf(outp,"%ld", r1->ru_majflt-r0->ru_majflt);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
- sprintf(outp,"%d", r1->ru_minflt-r0->ru_minflt);
|
||||
+ sprintf(outp,"%ld", r1->ru_minflt-r0->ru_minflt);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
- sprintf(outp,"%d", r1->ru_inblock-r0->ru_inblock);
|
||||
+ sprintf(outp,"%ld", r1->ru_inblock-r0->ru_inblock);
|
||||
END(outp);
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
- sprintf(outp,"%d", r1->ru_oublock-r0->ru_oublock);
|
||||
+ sprintf(outp,"%ld", r1->ru_oublock-r0->ru_oublock);
|
||||
END(outp);
|
||||
break;
|
||||
case 'C':
|
||||
@ -92,7 +212,7 @@
|
||||
r1->ru_nivcsw-r0->ru_nivcsw );
|
||||
END(outp);
|
||||
break;
|
||||
@@ -743,6 +748,7 @@
|
||||
@@ -743,6 +751,7 @@
|
||||
/*
|
||||
* N R E A D
|
||||
*/
|
||||
@ -100,7 +220,7 @@
|
||||
Nread( fd, buf, count )
|
||||
int fd;
|
||||
void *buf;
|
||||
@@ -752,7 +758,7 @@
|
||||
@@ -752,7 +761,7 @@
|
||||
int len = sizeof(from);
|
||||
register int cnt;
|
||||
if( udp ) {
|
||||
@ -109,7 +229,7 @@
|
||||
numCalls++;
|
||||
} else {
|
||||
if( b_flag )
|
||||
@@ -774,6 +780,7 @@
|
||||
@@ -774,6 +783,7 @@
|
||||
/*
|
||||
* N W R I T E
|
||||
*/
|
||||
@ -117,7 +237,7 @@
|
||||
Nwrite( fd, buf, count )
|
||||
int fd;
|
||||
void *buf;
|
||||
@@ -782,7 +789,7 @@
|
||||
@@ -782,7 +792,7 @@
|
||||
register int cnt;
|
||||
if( udp ) {
|
||||
again:
|
||||
@ -126,7 +246,7 @@
|
||||
numCalls++;
|
||||
if( cnt<0 && errno == ENOBUFS ) {
|
||||
delay(18000);
|
||||
@@ -803,7 +810,7 @@
|
||||
@@ -803,7 +813,7 @@
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = us;
|
||||
|
Loading…
Reference in New Issue
Block a user