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

jbaldwin / libcoro / 22549277350

01 Mar 2026 06:03PM UTC coverage: 86.142%. First build
22549277350

Pull #444

github

web-flow
Merge 020d34b2f into 0161911f2
Pull Request #444: scheduler remove lock for scheduled|resumed tasks

22 of 31 new or added lines in 4 files covered. (70.97%)

1871 of 2172 relevant lines covered (86.14%)

4825825.96 hits per line

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

47.14
/src/net/io_status.cpp
1
#include "coro/net/io_status.hpp"
2
#include <system_error>
3

4
#if defined(_WIN32)
5
    #ifndef WIN32_LEAN_AND_MEAN
6
        #define WIN32_LEAN_AND_MEAN
7
    #endif
8
    #include <windows.h>
9
    #include <winsock2.h>
10
#endif
11

12
std::string coro::net::io_status::message() const
×
13
{
14
    if (not is_native())
×
15
    {
16
        return std::string{to_string(type)};
×
17
    }
18

19
    if (native_code == 0)
×
20
    {
21
        return "Success";
×
22
    }
23

24
#if defined(_WIN32)
25
    char*  buffer = nullptr;
26
    size_t size   = FormatMessageA(
27
        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
28
        nullptr,
29
        static_cast<DWORD>(native_code),
30
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
31
        reinterpret_cast<LPSTR>(&buffer),
32
        0,
33
        nullptr);
34

35
    if (size > 0 && buffer)
36
    {
37
        std::string msg(buffer, size);
38
        LocalFree(buffer);
39
        return msg;
40
    }
41
#else // Linux/BSD
42
    try
43
    {
44
        return std::system_category().message(native_code);
×
45
    }
46
    catch (...)
×
47
    {
48
        return "Unknown system error" + std::to_string(native_code) + ")";
×
49
    }
×
50
#endif
51
}
52

53
auto coro::net::make_io_status_from_native(int native_code) -> coro::net::io_status
1,897,275✔
54
{
55
#if defined(_WIN32)
56
    #error "TODO: WIN32"
57
#else // Linux/BSD
58
    using kind = io_status::kind;
59
    kind type;
60
    switch (native_code)
1,897,275✔
61
    {
62
        case 0:
1✔
63
            type = kind::ok;
1✔
64
            break;
1✔
65
        case EOF:
1✔
66
            type = kind::closed;
1✔
67
            break;
1✔
68
        case ECONNREFUSED:
1✔
69
            type = kind::connection_refused;
1✔
70
            break;
1✔
71
        case ECONNRESET:
1✔
72
            type = kind::connection_reset;
1✔
73
            break;
1✔
74
        case EAGAIN:
2,036,167✔
75
    #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
76
        case EWOULDBLOCK:
77
    #endif
78
            type = kind::would_block_or_try_again;
2,036,167✔
79
            break;
2,036,167✔
80
        case EMSGSIZE:
1✔
81
            type = kind::message_too_big;
1✔
82
            break;
1✔
83
        default:
84
            type = kind::native;
85
            break;
86
    }
87
    return coro::net::io_status{.type = type, .native_code = native_code};
1,897,275✔
88
#endif
89
}
90
auto coro::net::make_io_status_from_poll_status(coro::poll_status status) -> coro::net::io_status
21✔
91
{
92
    switch (status)
21✔
93
    {
94
        case poll_status::read:
2✔
95
        case poll_status::write:
96
            return io_status{io_status::kind::ok};
2✔
97
        case poll_status::timeout:
15✔
98
            return io_status{io_status::kind::timeout};
15✔
99
        case poll_status::error:
1✔
100
            return io_status{io_status::kind::polling_error};
1✔
101
        case poll_status::closed:
1✔
102
            return io_status{io_status::kind::closed};
1✔
103
        case poll_status::cancelled:
2✔
104
            return io_status{io_status::kind::cancelled};
2✔
NEW
105
        default:
×
NEW
106
            return io_status{io_status::kind::unknown};
×
107
    }
108
}
109

110
auto coro::net::to_string(coro::net::io_status::kind k) -> std::string_view
×
111
{
112
    using kind = io_status::kind;
113
    switch (k)
×
114
    {
115
        case kind::ok:
×
116
            return "Success";
×
117
        case kind::closed:
×
118
            return "Connection closed by peer";
×
119
        case kind::connection_reset:
×
120
            return "Connection reset by peer";
×
121
        case kind::connection_refused:
×
122
            return "Connection refused by target host";
×
123
        case kind::timeout:
×
124
            return "Operation timed out";
×
125
        case kind::would_block_or_try_again:
×
126
            return "Operation would block or try again";
×
127
        case kind::polling_error:
×
128
            return "Polling error";
×
129
        case kind::cancelled:
×
130
            return "Operation cancelled";
×
131
        case kind::udp_not_bound:
×
132
            return "Udp socket is not bound";
×
133
        case kind::native:
×
134
            return "Native error code";
×
135
        case kind::message_too_big:
×
136
            return "Message is too big";
×
NEW
137
        case kind::unknown:
×
138
        default:
NEW
139
            return "unknown";
×
140
    }
141
}
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