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

test

parent 6d817e7d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include "exception.h"
#include "socket.h"
#include "eventapi.h"

namespace netplus {

@@ -128,6 +129,7 @@ void ssl::connect(const std::string& addr, int port, bool nonblock) {
    // with a timeout to prevent indefinite hangs on dead peers.
    // For non-blocking, the caller (e.g. epoll event loop) will drive it.
    if (!nonblock) {
        socketwait sw;
        auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(15);
        while (!_tls.getHandshakeDone()) {
            if (std::chrono::steady_clock::now() >= deadline) {
@@ -140,7 +142,16 @@ void ssl::connect(const std::string& addr, int port, bool nonblock) {
                _tls.flush_out();
            }
            // Drive the handshake state machine
            try {
                _tls.handshake_after_connect();
            } catch (NetException &e) {
                if (e.getErrorType() == NetException::Note) {
                    // Need more data from peer - wait for socket readability
                    sw.waitRead(*this, 100);
                    continue;
                }
                throw;
            }
        }
    }
}