Commit fe8f8bb2 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tls: test output congestion too

parent 42698f7c
...@@ -71,7 +71,7 @@ static void *tls_echo(void *data) ...@@ -71,7 +71,7 @@ static void *tls_echo(void *data)
vlc_tls_t *tls = data; vlc_tls_t *tls = data;
struct pollfd ufd; struct pollfd ufd;
ssize_t val; ssize_t val;
char buf[4096]; char buf[256];
ufd.fd = tls->fd; ufd.fd = tls->fd;
...@@ -222,6 +222,37 @@ int main(void) ...@@ -222,6 +222,37 @@ int main(void)
answer = 0; answer = 0;
val = securepair(&th, &tls, alpnv, NULL); val = securepair(&th, &tls, alpnv, NULL);
assert(val == 0); assert(val == 0);
/* Do a lot of I/O, test congestion handling */
static unsigned char data[16184];
size_t bytes = 0;
unsigned seed = 0;
do
{
for (size_t i = 0; i < sizeof (data); i++)
data[i] = rand_r(&seed);
bytes += sizeof (data);
}
while ((val = tls->send(tls, data, sizeof (data))) == sizeof (data));
bytes -= sizeof (data);
if (val > 0)
bytes += val;
fprintf(stderr, "Sent %zu bytes.\n", bytes);
seed = 0;
while (bytes > 0)
{
unsigned char c = rand_r(&seed);
val = vlc_tls_Read(tls, buf, 1, false);
assert(val == 1);
assert(c == (unsigned char)buf[0]);
bytes--;
}
vlc_tls_Close(tls); vlc_tls_Close(tls);
vlc_join(th, NULL); vlc_join(th, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment