New env var SOCAT_TRANSFER_WAIT: sleep before transfer loop

This commit is contained in:
Gerhard Rieger 2023-06-11 22:04:25 +02:00
parent a8b2cb68d5
commit 41b5da75ac
4 changed files with 20 additions and 2 deletions

View file

@ -1,4 +1,9 @@
 
Coding:
New Environment variable SOCAT_TRANSFER_WAIT that Socat sleep before
starting the data transfer loop. Useful, e.g., to accumulate multiple
packets in a receiving datagram socket before starting to process them.
####################### V 1.7.4.4: ####################### V 1.7.4.4:
Corrections: Corrections:

View file

@ -1 +1 @@
"1.7.4.4" "1.7.4.4+"

View file

@ -3652,8 +3652,16 @@ address format. If name resolution does not return a matching entry, the first
result (with differing IP version) is taken. With value 0, socat always selects result (with differing IP version) is taken. With value 0, socat always selects
the first record and its IP version. the first record and its IP version.
dit(bf(SOCAT_MAIN_WAIT) (input)) Specifies the time (seconds) to sleep the
main process on begin of main\(). Useful for debugging.
dit(bf(SOCAT_TRANSFER_WAIT) (input)) Specifies the time (seconds) to sleep the
process after opening addresses before entering the transfer loop. Useful for
debugging.
dit(bf(SOCAT_FORK_WAIT) (input)) Specifies the time (seconds) to sleep the dit(bf(SOCAT_FORK_WAIT) (input)) Specifies the time (seconds) to sleep the
parent and child processes after successful NOEXPAND(fork()). Useful for debugging. parent and child processes after successful NOEXPAND(fork()). Useful for
debugging.
dit(bf(SOCAT_VERSION) (output)) Socat sets this variable to its version string, dit(bf(SOCAT_VERSION) (output)) Socat sets this variable to its version string,
e.g. tt("1.7.0.0") for released versions or e.g. tt("1.6.0.1+envvar") for e.g. tt("1.7.0.0") for released versions or e.g. tt("1.6.0.1+envvar") for

View file

@ -782,6 +782,7 @@ bool maywr2; /* sock2 can be written to, according to poll() */
and their options are set/applied and their options are set/applied
returns -1 on error or 0 on success */ returns -1 on error or 0 on success */
int _socat(void) { int _socat(void) {
char *transferwaitstring;
struct pollfd fds[4], struct pollfd fds[4],
*fd1in = &fds[0], *fd1in = &fds[0],
*fd1out = &fds[1], *fd1out = &fds[1],
@ -851,6 +852,10 @@ int _socat(void) {
} }
total_timeout = socat_opts.total_timeout; total_timeout = socat_opts.total_timeout;
if (transferwaitstring = getenv("SOCAT_TRANSFER_WAIT")) {
Info1("before starting data transfer loop: sleeping %ds (env:SOCAT_TRANSFER_WAIT)", atoi(transferwaitstring));
sleep(atoi(transferwaitstring));
}
Notice4("starting data transfer loop with FDs [%d,%d] and [%d,%d]", Notice4("starting data transfer loop with FDs [%d,%d] and [%d,%d]",
XIO_GETRDFD(sock1), XIO_GETWRFD(sock1), XIO_GETRDFD(sock1), XIO_GETWRFD(sock1),
XIO_GETRDFD(sock2), XIO_GETWRFD(sock2)); XIO_GETRDFD(sock2), XIO_GETWRFD(sock2));