New upstream version 20211004+ds1
Peter Pentchev
2 years ago
0 | 0 | repo: 6e3b485d74645931e2408ed1f57e659029b5639a |
1 | node: 5a083db6c04c3286fabaa5e75021ee1d4e4ca3db | |
1 | node: 3b8642c23858eaa90737280ac2c0cd0761ecb62a | |
2 | 2 | branch: default |
3 | latesttag: R20210829 | |
4 | latesttagdistance: 1 | |
5 | changessincelatesttag: 1 | |
3 | tag: R20211004 |
0 | 20211004: | |
1 | - make TCPTimeout=0 disable the TCP timeout | |
2 | - changed default TCP timeout from 10s to 100s | |
3 | - TCP timeout now can be give with suffixes ms,s,min,h | |
4 | - documented option for TCP timeout | |
5 | ||
0 | 6 | 20210829: |
1 | 7 | - enhancement: accept IPv6 addresses in square bracket format |
2 | 8 | - enhancement: more detailed warning message for connect failures |
142 | 142 | fail with 'no space left', indicating the real end of the tape. This will allow |
143 | 143 | a little extra data to fit on each tape. |
144 | 144 | .TP |
145 | \fB\-\-tcptimeo\fR <\fItime\fP> | |
146 | Set the TCP timeout threshold. The default value is 10s. Arguments | |
147 | without dimension are interpreted as usec. Argument dimensions can be | |
148 | us, ms, s or sec, m or min, h. | |
145 | 149 | \fB\-6\fR |
146 | 150 | Force IPv6 mode for the following network I/O options on command line. |
147 | 151 | \fB\-4\fR |
72 | 72 | # TCPbufsize = 0 |
73 | 73 | |
74 | 74 | ## TCP transmission timeout [msec] |
75 | # TCPtimeout = 0 | |
75 | # accepts dimensions sec,s,ms,us,min,h | |
76 | # TCPtimeout = 100s | |
76 | 77 | |
77 | 78 | ## tape aware out-of-space handling |
78 | 79 | ## valid values are: true, false, 0, 1, on, off |
0 | #!/bin/bash -x | |
0 | #!/bin/bash | |
1 | 1 | |
2 | 2 | VERSION_H=${1:-version.h} |
3 | 3 | NEWFILE=`mktemp -t version.h.XXXXXXXXXX` |
24 | 24 | |
25 | 25 | |
26 | 26 | #include <errno.h> |
27 | #include <math.h> | |
27 | 28 | #include <netdb.h> |
28 | 29 | #include <net/if.h> |
29 | 30 | #include <stdio.h> |
43 | 44 | #include "settings.h" |
44 | 45 | #include "log.h" |
45 | 46 | |
46 | int32_t TCPBufSize = 0, TCPTimeout = 10000000; | |
47 | int32_t TCPBufSize = 0; | |
48 | double TCPTimeout = 100; | |
47 | 49 | #if defined(PF_INET6) && defined(PF_UNSPEC) |
48 | 50 | int AddrFam = PF_UNSPEC; |
49 | 51 | #else |
247 | 249 | if (TCPBufSize) |
248 | 250 | setTCPBufferSize(In,SO_RCVBUF); |
249 | 251 | struct timeval timeo; |
250 | timeo.tv_sec = TCPTimeout/1000000; | |
251 | timeo.tv_usec = TCPTimeout%1000000; | |
252 | timeo.tv_sec = floor(TCPTimeout); | |
253 | timeo.tv_usec = TCPTimeout-timeo.tv_sec*1000000; | |
252 | 254 | if (-1 == setsockopt(In, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo))) |
253 | 255 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); |
256 | else | |
257 | debugmsg("disabled TCP receive timeout\n"); | |
254 | 258 | (void) close(sock); |
255 | 259 | } |
256 | 260 | |
306 | 310 | } else { |
307 | 311 | if (TCPBufSize) |
308 | 312 | setTCPBufferSize(fd,SO_SNDBUF); |
309 | struct timeval timeo; | |
310 | timeo.tv_sec = TCPTimeout/1000000; | |
311 | timeo.tv_usec = TCPTimeout%1000000; | |
312 | if (-1 == setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo))) | |
313 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); | |
313 | if (TCPTimeout) { | |
314 | struct timeval timeo; | |
315 | timeo.tv_sec = floor(TCPTimeout); | |
316 | timeo.tv_usec = (TCPTimeout-timeo.tv_sec)*1E6; | |
317 | if (-1 == setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo))) | |
318 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); | |
319 | } else { | |
320 | debugmsg("disabled TCP send timeout\n"); | |
321 | } | |
314 | 322 | } |
315 | 323 | d = (dest_t *) malloc(sizeof(dest_t)); |
316 | 324 | d->arg = addr; |
381 | 389 | if (host[0] == 0) { |
382 | 390 | infomsg("accepted connection from %s\n",inet_ntoa(caddr.sin_addr)); |
383 | 391 | (void) close(sock); |
384 | struct timeval timeo; | |
385 | timeo.tv_sec = TCPTimeout/1000000; | |
386 | timeo.tv_usec = TCPTimeout%1000000; | |
387 | if (-1 == setsockopt(In, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo))) | |
388 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); | |
392 | if (TCPTimeout) { | |
393 | struct timeval timeo; | |
394 | timeo.tv_sec = floor(TCPTimeout); | |
395 | timeo.tv_usec = (TCPTimeout-timeo.tv_sec)*1000000; | |
396 | if (-1 == setsockopt(In, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo))) | |
397 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); | |
398 | else | |
399 | infomsg("set TCP receive timeout to %usec, %uusec\n",timeo.tv_sec,timeo.tv_usec); | |
400 | } else { | |
401 | debugmsg("disabled TCP receive timeout\n"); | |
402 | } | |
389 | 403 | return; |
390 | 404 | } |
391 | 405 | for (p = h->h_addr_list; *p; ++p) { |
489 | 503 | errormsg("could not connect to %s:%s: %s\n",dest->name,dest->port,dest->result); |
490 | 504 | (void) close(out); |
491 | 505 | out = -1; |
492 | } else { | |
506 | } else if (TCPTimeout) { | |
493 | 507 | struct timeval timeo; |
494 | timeo.tv_sec = TCPTimeout/1000000; | |
495 | timeo.tv_usec = TCPTimeout%1000000; | |
508 | timeo.tv_sec = floor(TCPTimeout); | |
509 | timeo.tv_usec = (TCPTimeout-timeo.tv_sec)*1000000; | |
496 | 510 | if (-1 == setsockopt(out, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo))) |
497 | 511 | warningmsg("cannot set socket send timeout: %s\n",strerror(errno)); |
512 | else | |
513 | infomsg("set TCP transmit timeout to %usec, %uusec\n",timeo.tv_sec,timeo.tv_usec); | |
514 | } else { | |
515 | debugmsg("disabled TCP transmint timeout\n"); | |
516 | ||
498 | 517 | } |
499 | 518 | dest->fd = out; |
500 | 519 | } |
94 | 94 | *Tmpfile = 0; |
95 | 95 | |
96 | 96 | extern void *watchdogThread(void *ignored); |
97 | ||
97 | 98 | |
98 | 99 | static const char *calcval(const char *arg, unsigned long long *res) |
99 | 100 | { |
154 | 155 | } |
155 | 156 | |
156 | 157 | |
158 | static double calctime(const char *str, double def) | |
159 | { | |
160 | char dim[8]; | |
161 | double d = (double)def; | |
162 | ||
163 | dim[0] = 0; | |
164 | int n = sscanf(str,"%lf%7s",&d,dim); | |
165 | if ((n <= 0) || (n > 2)) { | |
166 | errormsg("invalid time argument \"%s\"\n",str); | |
167 | d = def; | |
168 | } | |
169 | if (0 == dim[0]) { | |
170 | d *= 1E-3; | |
171 | } else if (0 == strcmp(dim,"ms")) { | |
172 | d *= 1E-3; | |
173 | } else if (0 == strcmp(dim,"msec")) { | |
174 | d *= 1E-3; | |
175 | } else if (0 == strcmp(dim,"s")) { | |
176 | ||
177 | } else if (0 == strcmp(dim,"m")) { | |
178 | d *= 60; | |
179 | } else if (0 == strcmp(dim,"min")) { | |
180 | d *= 60; | |
181 | } else if (0 == strcmp(dim,"h")) { | |
182 | d *= 60 * 60; | |
183 | } else { | |
184 | errormsg("invalid time dimension in argument \"%s\"\n",str); | |
185 | d = def; | |
186 | } | |
187 | return d; | |
188 | } | |
189 | ||
190 | ||
157 | 191 | static int isEmpty(const char *l) |
158 | 192 | { |
159 | 193 | while (*l) { |
408 | 442 | TCPBufSize = value; |
409 | 443 | debugmsg("TCPBufSize = %lu\n",TCPBufSize); |
410 | 444 | } else if (strcasecmp(key,"tcptimeout") == 0) { |
411 | TCPTimeout = value; | |
412 | debugmsg("TCPTimeout = %lu\n",TCPTimeout); | |
445 | TCPTimeout = calctime(valuestr,TCPTimeout); | |
446 | debugmsg("TCPTimeout = %f\n",TCPTimeout); | |
413 | 447 | } else { |
414 | 448 | warningmsg("unknown parameter: %s\n",key); |
415 | 449 | } |
640 | 674 | ); |
641 | 675 | exit(EXIT_SUCCESS); |
642 | 676 | } |
677 | ||
643 | 678 | |
644 | 679 | |
645 | 680 | static unsigned long long calcint(const char **argv, int c, unsigned long long def) |
759 | 794 | TCPBufSize = calcint(argv,++c,TCPBufSize); |
760 | 795 | debugmsg("TCPBufSize = %lu\n",TCPBufSize); |
761 | 796 | } else if (!strcmp("--tcptimeo",argv[c])) { |
762 | TCPTimeout = calcint(argv,++c,TCPTimeout); | |
763 | debugmsg("TCPTimeout = %lu\n",TCPTimeout); | |
797 | TCPTimeout = calctime(argv[++c],TCPTimeout); | |
798 | debugmsg("TCPTimeout = %lf\n",TCPTimeout); | |
764 | 799 | } else if (!strcmp("--tapeaware",argv[c])) { |
765 | 800 | TapeAware = 1; |
766 | 801 | debugmsg("sensing early end-of-tape warning\n"); |
0 | 0 | /* |
1 | * Copyright (C) 2000-2020, Thomas Maier-Komor | |
1 | * Copyright (C) 2000-2021, Thomas Maier-Komor | |
2 | 2 | * |
3 | 3 | * This is the source code of mbuffer. |
4 | 4 | * |
22 | 22 | #include <time.h> |
23 | 23 | #include <sys/types.h> |
24 | 24 | |
25 | extern int32_t TCPBufSize, TCPTimeout; | |
25 | extern int32_t TCPBufSize; | |
26 | extern double TCPTimeout; | |
26 | 27 | |
27 | 28 | extern clockid_t |
28 | 29 | ClockSrc; |