Skip to content

Commit

Permalink
Merge pull request #5205 from rgerhards/tcpflood-no-abort-send-fail
Browse files Browse the repository at this point in the history
Make imptcp_maxsessions test (much more) reliable
  • Loading branch information
rgerhards committed Jul 31, 2023
2 parents 27e1da2 + 37de8f6 commit d47fa8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tests/imptcp_maxsessions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ startup
echo "INFO: RSYSLOG_OUT_LOG: $RSYSLOG_OUT_LOG"

echo "About to run tcpflood"
tcpflood -c$CONNECTIONS -m$NUMMESSAGES -r -d100 -P129
tcpflood -c$CONNECTIONS -m$NUMMESSAGES -r -d100 -P129 -A
echo "-------> NOTE: CLOSED REMOTELY messages are expected and OK! <-------"
echo "done run tcpflood"
shutdown_when_empty
wait_shutdown
Expand Down
24 changes: 18 additions & 6 deletions tests/tcpflood.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* -z private key file for TLS mode
* -Z cert (public key) file for TLS mode
* -a Authentication Mode for relp-tls
* -A do NOT abort if an error occured during sending messages
* -E Permitted Peer for relp-tls
* -L loglevel to use for GnuTLS troubleshooting (0-off to 10-all, 0 default)
* -j format message in json, parameter is JSON cookie
Expand Down Expand Up @@ -208,6 +209,7 @@ static long long batchsize = 100000000ll;
static int waittime = 0;
static int runMultithreaded = 0; /* run tests in multithreaded mode */
static int numThrds = 1; /* number of threads to use */
static int abortOnSendFail = 1; /* abort run if sending fails? */
static char *tlsCAFile = NULL;
static char *tlsCertFile = NULL;
static char *tlsKeyFile = NULL;
Expand Down Expand Up @@ -793,13 +795,21 @@ int sendMessages(struct instdata *inst)
printf("\r%5.5u\n", i);
fflush(stdout);
test_rs_strerror_r(error_number, errStr, sizeof(errStr));
printf("send() failed \"%s\" at socket %d, index %u, msgNum %lld, "
"lenSend %zd, lenBuf %zd\n",
errStr, sockArray[socknum], i, inst->numSent, lenSend,
lenBuf);
if(lenSend == 0) {
printf("tcpflood: socket %d, index %u, msgNum %lld CLOSED REMOTELY\n",
sockArray[socknum], i, inst->numSent);
} else {
printf("tcpflood: send() failed \"%s\" at socket %d, index %u, "
"msgNum %lld, lenSend %zd, lenBuf %zd\n",
errStr, sockArray[socknum], i, inst->numSent, lenSend,
lenBuf);
}
fflush(stderr);

return(1);
if(abortOnSendFail) {
printf("tcpflood terminates due to send failure\n");
return(1);
}
}
if(i % show_progress_interval == 0) {
if(bShowProgress)
Expand Down Expand Up @@ -1629,7 +1639,7 @@ int main(int argc, char *argv[])

setvbuf(stdout, buf, _IONBF, 48);

while((opt = getopt(argc, argv, "a:Bb:c:C:d:DeE:f:F:i:I:j:k:l:L:m:M:n:OP:p:rR:sS:t:T:u:vW:x:XyYz:Z:")) != -1) {
while((opt = getopt(argc, argv, "a:ABb:c:C:d:DeE:f:F:i:I:j:k:l:L:m:M:n:OP:p:rR:sS:t:T:u:vW:x:XyYz:Z:")) != -1) {
switch (opt) {
case 'b': batchsize = atoll(optarg);
break;
Expand Down Expand Up @@ -1737,6 +1747,8 @@ int main(int argc, char *argv[])
break;
case 'a': relpAuthMode = optarg;
break;
case 'A': abortOnSendFail = 0;
break;
case 'E': relpPermittedPeer = optarg;
break;
case 'u':
Expand Down

0 comments on commit d47fa8d

Please sign in to comment.