summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-02-04 09:22:58 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-02-04 09:22:58 +0100
commit233157e520045ef4e05687b0db3b41692ffce5fd (patch)
tree05bbf5d51cbe4be2f4643727ccd478569f799236
parent0c880a4a30b7d390f8d45491fa6c5186dbe6c117 (diff)
downloadrsyslog-233157e520045ef4e05687b0db3b41692ffce5fd.tar.gz
rsyslog-233157e520045ef4e05687b0db3b41692ffce5fd.tar.xz
rsyslog-233157e520045ef4e05687b0db3b41692ffce5fd.zip
experiemental milestone: tcpflood support buffering in TLS mode
This needs to be checked, it is not yet 100% correct
-rw-r--r--tests/tcpflood.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index eb2259ec..b0a40924 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -100,6 +100,7 @@
#define NETTEST_INPUT_CONF_FILE "nettest.input.conf" /* name of input file, must match $IncludeConfig in .conf files */
#define MAX_EXTRADATA_LEN 100*1024
+#define MAX_SENDBUF 2 * MAX_EXTRADATA_LEN
static char *targetIP = "127.0.0.1";
static char *msgPRI = "167";
@@ -397,6 +398,8 @@ int sendMessages(struct instdata *inst)
int lenSend = 0;
char *statusText = "";
char buf[MAX_EXTRADATA_LEN + 1024];
+ char sendBuf[MAX_SENDBUF];
+ int offsSendBuf = 0;
if(!bSilent) {
if(dataFile == NULL) {
@@ -438,7 +441,16 @@ int sendMessages(struct instdata *inst)
} else if(transport == TP_UDP) {
lenSend = sendto(udpsock, buf, lenBuf, 0, &udpRcvr, sizeof(udpRcvr));
} else if(transport == TP_TLS) {
- lenSend = sendTLS(socknum, buf, lenBuf);
+ if(offsSendBuf + lenBuf < MAX_SENDBUF) {
+ memcpy(sendBuf+offsSendBuf, buf, lenBuf);
+ offsSendBuf += lenBuf;
+ lenSend = lenBuf; /* simulate "good" call */
+ } else {
+ lenSend = sendTLS(socknum, sendBuf, offsSendBuf);
+ lenSend = (lenSend == offsSendBuf) ? lenBuf : -1;
+ memcpy(sendBuf, buf, lenBuf);
+ offsSendBuf = lenBuf;
+ }
}
if(lenSend != lenBuf) {
printf("\r%5.5d\n", i);
@@ -469,6 +481,11 @@ int sendMessages(struct instdata *inst)
++msgNum;
++i;
}
+ if(transport == TP_TLS && offsSendBuf != 0) {
+ /* send remaining buffer */
+ lenSend = sendTLS(socknum, sendBuf, offsSendBuf);
+printf("TLS send buffer of %d messages remaining, sent %d\n", offsSendBuf, lenSend);
+ }
if(!bSilent)
printf("\r%8.8d %s sent\n", i, statusText);
@@ -731,7 +748,18 @@ initTLSSess(int i)
static int
sendTLS(int i, char *buf, int lenBuf)
{
- return gnutls_record_send(sessArray[i], buf, lenBuf);
+ int lenSent;
+ int r;
+
+ lenSent = 0;
+ while(lenSent != lenBuf) {
+ r = gnutls_record_send(sessArray[i], buf + lenSent, lenBuf - lenSent);
+ if(r < 0)
+ break;
+ lenSent += r;
+ }
+
+ return lenSent;
}
static void