New upstream version 20211018+ds1
Peter Pentchev
2 years ago
0 | 0 | repo: 6e3b485d74645931e2408ed1f57e659029b5639a |
1 | node: 3b8642c23858eaa90737280ac2c0cd0761ecb62a | |
1 | node: 031876543708de476cc59c9eec9361869641c27e | |
2 | 2 | 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 | ||
0 | 5 | 20211004: |
1 | 6 | - make TCPTimeout=0 disable the TCP timeout |
2 | 7 | - changed default TCP timeout from 10s to 100s |
6 | 6 | .SH "DESCRIPTION" |
7 | 7 | .LP |
8 | 8 | 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. | |
11 | 11 | .SH "OPTIONS" |
12 | 12 | .LP |
13 | 13 | .TP |
18 | 18 | .TP |
19 | 19 | \fB\-I\fR <\fIport\fP> |
20 | 20 | 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. | |
23 | 23 | .TP |
24 | 24 | \fB\-o\fR <\fIfilename\fP> |
25 | 25 | Use \fIfilename\fP as output instead of the standard output (needs to be |
146 | 146 | Set the TCP timeout threshold. The default value is 10s. Arguments |
147 | 147 | without dimension are interpreted as usec. Argument dimensions can be |
148 | 148 | us, ms, s or sec, m or min, h. |
149 | .TP | |
149 | 150 | \fB\-6\fR |
150 | 151 | Force IPv6 mode for the following network I/O options on command line. |
152 | .TP | |
151 | 153 | \fB\-4\fR |
152 | 154 | Force IPv4 mode for the following network I/O options on command line. |
155 | .TP | |
153 | 156 | \fB\-0\fR |
154 | 157 | Choose IPv4/IPv6 mode on demand. |
155 | 158 | .TP |
182 | 185 | trigger during network initialization, put the option -W after -I and |
183 | 186 | -O. |
184 | 187 | .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. | |
215 | 205 | |
216 | 206 | .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 | |
218 | 208 | 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. | |
219 | 211 | .SH "FILES" |
220 | 212 | .LP |
221 | 213 | \fI$PREFIX/bin/mbuffer\fP |
1048 | 1048 | dfname[l++] = '/'; |
1049 | 1049 | memcpy(dfname+l,".mbuffer.rc",12); |
1050 | 1050 | readConfigFile(dfname); |
1051 | const char *userrc = getenv("MBUFFERRC"); | |
1052 | if (userrc) | |
1053 | readConfigFile(userrc); | |
1051 | 1054 | } |
1052 | 1055 | |
1053 | 1056 |
0 | 0 | #!/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 | ||
1 | 20 | |
2 | 21 | VERSION_H=${1:-version.h} |
3 | 22 | NEWFILE=`mktemp -t version.h.XXXXXXXXXX` |
68 | 87 | if [ ! -f version.h ]; then |
69 | 88 | echo creating version.h |
70 | 89 | mv $NEWFILE $VERSION_H |
90 | echo creating man-page | |
71 | 91 | $SED "s/@VERSION@/$VER/" < mbuffer.1.in > mbuffer.1 |
72 | 92 | exit |
73 | 93 | fi |
248 | 248 | debugmsg("input connection accepted\n"); |
249 | 249 | if (TCPBufSize) |
250 | 250 | 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 { | |
257 | 258 | debugmsg("disabled TCP receive timeout\n"); |
259 | } | |
258 | 260 | (void) close(sock); |
259 | 261 | } |
260 | 262 |
106 | 106 | abort(); |
107 | 107 | break; |
108 | 108 | case 2: |
109 | if (d <= 0) | |
109 | if (d < 0) | |
110 | 110 | return "negative value out of range"; |
111 | 111 | switch (ch) { |
112 | 112 | case 'k': |
144 | 144 | return "invalid dimension"; |
145 | 145 | } |
146 | 146 | case 1: |
147 | if (d <= 0) | |
147 | if (d < 0) | |
148 | 148 | return "value out of range"; |
149 | 149 | *res = d; |
150 | 150 | return 0; |
414 | 414 | } |
415 | 415 | } else if (strcasecmp(key,"verbose") == 0) { |
416 | 416 | setVerbose(valuestr); |
417 | } else if (strcasecmp(key,"tcptimeout") == 0) { | |
418 | TCPTimeout = calctime(valuestr,TCPTimeout); | |
419 | debugmsg("TCPTimeout = %f\n",TCPTimeout); | |
417 | 420 | } else { |
418 | 421 | unsigned long long value = 0; |
419 | 422 | const char *argerror = calcval(valuestr,&value); |
441 | 444 | } else if (strcasecmp(key,"tcpbufsize") == 0) { |
442 | 445 | TCPBufSize = value; |
443 | 446 | debugmsg("TCPBufSize = %lu\n",TCPBufSize); |
444 | } else if (strcasecmp(key,"tcptimeout") == 0) { | |
445 | TCPTimeout = calctime(valuestr,TCPTimeout); | |
446 | debugmsg("TCPTimeout = %f\n",TCPTimeout); | |
447 | 447 | } else { |
448 | 448 | warningmsg("unknown parameter: %s\n",key); |
449 | 449 | } |