Codebase list mbuffer / 397ba4c
New upstream version 20211018+ds1 Peter Pentchev 2 years ago
7 changed file(s) with 70 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
00 repo: 6e3b485d74645931e2408ed1f57e659029b5639a
1 node: 3b8642c23858eaa90737280ac2c0cd0761ecb62a
1 node: 031876543708de476cc59c9eec9361869641c27e
22 branch: default
3 tag: R20211004
3 tag: R20211018
0 20211018:
1 - fixes related to TCP timeout handling
2 - enhancement: support setting config file via env var MBUFFERRC
3 - documentation update
4
05 20211004:
16 - make TCPTimeout=0 disable the TCP timeout
27 - changed default TCP timeout from 10s to 100s
66 .SH "DESCRIPTION"
77 .LP
88 mbuffer buffers I/O operations and displays the throughput rate. It is
9 multi-threaded, supports network connections, and offers more options
10 than the standard buffer.
9 multi-threaded, supports network connections, multiple output targets,
10 and many more options than the standard buffer command.
1111 .SH "OPTIONS"
1212 .LP
1313 .TP
1818 .TP
1919 \fB\-I\fR <\fIport\fP>
2020 Use network port \fIport\fP as input instead of the standard input. If
21 given a hostname and a port in the form hostname:port, the first interface
22 with the IP of hostname will be used.
21 given a hostname and a port in the form \fIhostname:port\fP, the first
22 interface with the IP of hostname will be used.
2323 .TP
2424 \fB\-o\fR <\fIfilename\fP>
2525 Use \fIfilename\fP as output instead of the standard output (needs to be
146146 Set the TCP timeout threshold. The default value is 10s. Arguments
147147 without dimension are interpreted as usec. Argument dimensions can be
148148 us, ms, s or sec, m or min, h.
149 .TP
149150 \fB\-6\fR
150151 Force IPv6 mode for the following network I/O options on command line.
152 .TP
151153 \fB\-4\fR
152154 Force IPv4 mode for the following network I/O options on command line.
155 .TP
153156 \fB\-0\fR
154157 Choose IPv4/IPv6 mode on demand.
155158 .TP
182185 trigger during network initialization, put the option -W after -I and
183186 -O.
184187 .SH "DEFAULT VALUES"
185 The default values for following options can be set as \fIkey = value\fP pairs
186 in the ~/.mbuffer.rc file:
187 .br
188 \fIblocksize\fP: block size (option \-s)
189 .br
190 \fItimeout\fP: watchdog timeout (option \-W)
191 .br
192 \fItotalmem\fP: total buffer size (option \-m)
193 .br
194 \fImaxreadspeed\fP: maximum read speed (option \-r)
195 .br
196 \fImaxwritespeed\fP: maximum write speed (option \-R)
197 .br
198 \fIstartwrite\fP: threshold for start writing (option \-P)
199 .br
200 \fIstartread\fP: threshold for start reading (option \-p)
201 .br
202 \fIpause\fP: pause after writing a block (option \-u)
203 .br
204 \fInumblocks\fP: number of blocks in buffer (option \-b)
205 .br
206 \fImemlock\fP: lock buffer in memory (option \-L)
207 .br
208 \fIshowstatus\fP: print transfer status on console (option \-q)
209 .br
210 \fIlogstatus\fP: write transfer status to logfile (option \-Q)
211 .br
212 \fItcpbuffer\fP: TCP buffer size (option \-\-tcpbuffer)
213 .br
214
188 The default values for most options can be set as \fIkey = value\fP pairs
189 in one or more configuration files. See the sample \fImbuffer.rc\fP
190 files for available options and their default values. Configuration
191 files are read in following sequence listed below:
192 .LP
193 .br
194 - \fI/etc/mbuffer.rc\fR
195 .br
196 - \fB$PREFIX\fI/etc/mbuffer.rc\fR
197 .br
198 - \fB$HOME\fI/.mbuffer.rc\fR
199 .br
200 - \fB$MBUFFERRC\fR
201 .br
202 .LP
203 The default values given in the files above are overriden by options
204 passed on the command-line.
215205
216206 .SH "ENVIRONMENT VARIABLES"
217 If TMPDIR is set, mbuffer allocates storage for file-based buffers in this
207 If \fBTMPDIR\fR is set, mbuffer allocates storage for file-based buffers in this
218208 directory\&. If TMPDIR is unset, \fI/var/tmp\fR will be used\&.
209
210 \fBMBUFFERRC\fP can be used to set a custom mbuffer.rc config file.
219211 .SH "FILES"
220212 .LP
221213 \fI$PREFIX/bin/mbuffer\fP
10481048 dfname[l++] = '/';
10491049 memcpy(dfname+l,".mbuffer.rc",12);
10501050 readConfigFile(dfname);
1051 const char *userrc = getenv("MBUFFERRC");
1052 if (userrc)
1053 readConfigFile(userrc);
10511054 }
10521055
10531056
00 #!/bin/bash
1 #
2 # Copyright (C) 2000-2021, Thomas Maier-Komor
3 #
4 # This source file is part of mbuffer.
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19
120
221 VERSION_H=${1:-version.h}
322 NEWFILE=`mktemp -t version.h.XXXXXXXXXX`
6887 if [ ! -f version.h ]; then
6988 echo creating version.h
7089 mv $NEWFILE $VERSION_H
90 echo creating man-page
7191 $SED "s/@VERSION@/$VER/" < mbuffer.1.in > mbuffer.1
7292 exit
7393 fi
248248 debugmsg("input connection accepted\n");
249249 if (TCPBufSize)
250250 setTCPBufferSize(In,SO_RCVBUF);
251 struct timeval timeo;
252 timeo.tv_sec = floor(TCPTimeout);
253 timeo.tv_usec = TCPTimeout-timeo.tv_sec*1000000;
254 if (-1 == setsockopt(In, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo)))
255 warningmsg("cannot set socket send timeout: %s\n",strerror(errno));
256 else
251 if (TCPTimeout > 0) {
252 struct timeval timeo;
253 timeo.tv_sec = floor(TCPTimeout);
254 timeo.tv_usec = (TCPTimeout-timeo.tv_sec)*1000000;
255 if (-1 == setsockopt(In, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo)))
256 warningmsg("cannot set socket send timeout: %s\n",strerror(errno));
257 } else {
257258 debugmsg("disabled TCP receive timeout\n");
259 }
258260 (void) close(sock);
259261 }
260262
106106 abort();
107107 break;
108108 case 2:
109 if (d <= 0)
109 if (d < 0)
110110 return "negative value out of range";
111111 switch (ch) {
112112 case 'k':
144144 return "invalid dimension";
145145 }
146146 case 1:
147 if (d <= 0)
147 if (d < 0)
148148 return "value out of range";
149149 *res = d;
150150 return 0;
414414 }
415415 } else if (strcasecmp(key,"verbose") == 0) {
416416 setVerbose(valuestr);
417 } else if (strcasecmp(key,"tcptimeout") == 0) {
418 TCPTimeout = calctime(valuestr,TCPTimeout);
419 debugmsg("TCPTimeout = %f\n",TCPTimeout);
417420 } else {
418421 unsigned long long value = 0;
419422 const char *argerror = calcval(valuestr,&value);
441444 } else if (strcasecmp(key,"tcpbufsize") == 0) {
442445 TCPBufSize = value;
443446 debugmsg("TCPBufSize = %lu\n",TCPBufSize);
444 } else if (strcasecmp(key,"tcptimeout") == 0) {
445 TCPTimeout = calctime(valuestr,TCPTimeout);
446 debugmsg("TCPTimeout = %f\n",TCPTimeout);
447447 } else {
448448 warningmsg("unknown parameter: %s\n",key);
449449 }