• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jbaldwin / libcoro / 18355807267

08 Oct 2025 07:27PM UTC coverage: 88.651%. First build
18355807267

Pull #400

github

web-flow
Merge 82d22144f into 749e5b474
Pull Request #400: Executor types remove circular refs

48 of 56 new or added lines in 15 files covered. (85.71%)

1656 of 1868 relevant lines covered (88.65%)

5382608.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/src/net/tls/server.cpp
1
#ifdef LIBCORO_FEATURE_TLS
2

3
    #include "coro/net/tls/server.hpp"
4

5
    #include "coro/io_scheduler.hpp"
6

7
namespace coro::net::tls
8
{
9
server::server(std::unique_ptr<coro::io_scheduler>& scheduler, std::shared_ptr<context> tls_ctx, options opts)
2✔
10
    : m_io_scheduler(scheduler.get()),
2✔
11
      m_tls_ctx(std::move(tls_ctx)),
2✔
12
      m_options(std::move(opts)),
2✔
13
      m_accept_socket(net::make_accept_socket(
2✔
14
          net::socket::options{net::domain_t::ipv4, net::socket::type_t::tcp, net::socket::blocking_t::no},
×
15
          m_options.address,
2✔
16
          m_options.port,
2✔
17
          m_options.backlog))
18
{
19
    if (m_io_scheduler == nullptr)
2✔
20
    {
21
        throw std::runtime_error{"tls::server cannot have a nullptr io_scheduler"};
×
22
    }
23

24
    if (m_tls_ctx == nullptr)
2✔
25
    {
26
        throw std::runtime_error{"tls::server cannot have a nullptr tls_ctx"};
×
27
    }
28
}
2✔
29

30
server::server(server&& other)
×
NEW
31
    : m_io_scheduler(std::exchange(other.m_io_scheduler, nullptr)),
×
32
      m_tls_ctx(std::move(other.m_tls_ctx)),
×
33
      m_options(std::move(other.m_options)),
×
34
      m_accept_socket(std::move(other.m_accept_socket))
×
35
{
36
}
×
37

38
auto server::operator=(server&& other) -> server&
×
39
{
40
    if (std::addressof(other) != this)
×
41
    {
NEW
42
        m_io_scheduler  = std::exchange(other.m_io_scheduler, nullptr);
×
43
        m_tls_ctx       = std::move(other.m_tls_ctx);
×
44
        m_options       = std::move(other.m_options);
×
45
        m_accept_socket = std::move(other.m_accept_socket);
×
46
    }
47
    return *this;
×
48
}
49

50
auto server::accept(std::chrono::milliseconds timeout) -> coro::task<coro::net::tls::client>
101✔
51
{
52
    sockaddr_in         client{};
53
    constexpr const int len = sizeof(struct sockaddr_in);
54
    net::socket         s{::accept(
55
        m_accept_socket.native_handle(),
56
        reinterpret_cast<struct sockaddr*>(&client),
57
        const_cast<socklen_t*>(reinterpret_cast<const socklen_t*>(&len)))};
58

59
    std::span<const uint8_t> ip_addr_view{
60
        reinterpret_cast<uint8_t*>(&client.sin_addr.s_addr),
61
        sizeof(client.sin_addr.s_addr),
62
    };
63

64
    auto tls_client = tls::client{
65
        m_io_scheduler,
66
        m_tls_ctx,
67
        std::move(s),
68
        tls::client::options{
69
            .address = net::ip_address{ip_addr_view, static_cast<net::domain_t>(client.sin_family)},
70
            .port    = ntohs(client.sin_port),
71
        }};
72

73
    auto hstatus = co_await tls_client.handshake(timeout);
74
    (void)hstatus; // user must check result.
75
    co_return std::move(tls_client);
76
};
202✔
77

78
} // namespace coro::net::tls
79

80
#endif // #ifdef LIBCORO_FEATURE_TLS
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc