Commit 7f078db5 authored by jan.koester's avatar jan.koester
Browse files

test

parent 9ea373ef
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -8,10 +8,8 @@
#include <chrono>
#include <numeric>
#ifdef _WIN32
#define NOMINMAX
#include <winsock2.h>
#define poll WSAPoll
#else
#include <poll.h>
#endif

#include "connection.h"
@@ -203,22 +201,13 @@ static void benchmark_tls_transfer(size_t payload_size, int iterations,
    int send_idx = 0;
    size_t send_off = 0;  // offset within current payload iteration

    struct pollfd pfd;
    pfd.fd = client.fd();
    socketwait sw;

    auto t0 = hrc::now();

    while (total_recv < target_bytes) {
        // Poll for readable or writable (or both)
        pfd.events = POLLIN;
        if (send_idx < iterations) pfd.events |= POLLOUT;
        pfd.revents = 0;

        int pr = poll(&pfd, 1, (send_idx >= iterations) ? 500 : 10);
        if (pr < 0) break;

        // Try to send (writable or just attempt it)
        if ((pfd.revents & POLLOUT) && send_idx < iterations) {
        // Try to send (writable)
        if (send_idx < iterations && sw.waitWrite(client, 0)) {
            size_t chunk = std::min(payload_size - send_off, size_t(16384));
            buffer snd(payload.data() + send_off, chunk);
            try {
@@ -236,7 +225,7 @@ static void benchmark_tls_transfer(size_t payload_size, int iterations,
        }

        // Try to receive (readable)
        if (pfd.revents & POLLIN) {
        if (sw.waitRead(client, (send_idx >= iterations) ? 500 : 10)) {
            // Drain all available data
            bool more = true;
            while (more) {