8000 Aeron socket/transport return codes lose context, resulting in erroneous short send reports · Issue #1756 · aeron-io/aeron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Aeron socket/transport return codes lose context, resulting in erroneous short send reports #1756
Open
@klittlepage

Description

@klittlepage

Methods such as

ssize_t aeron_send(aeron_socket_t fd, const void *buf, size_t len, int flags)
return 0 when the underlying socket returns EAGAIN, EWOULDBLOCK, ECONNREFUSED, EINTR. This results in methods that check for short sends with logic equivalent to 0 <= result && bytes_sent < (int64_t)iov.iov_len erroneously reporting a short send. This is notably problematic for aeron_network_publication_setup_message_check and aeron_network_publication_heartbeat_message_check, as ECONNREFUSED is a likely status in both cases when using multicast.

if (0 <= (result = aeron_network_publication_do_send(publication, &iov, 1, &bytes_sent)))
{
if (bytes_sent < (int64_t)iov.iov_len)
{
aeron_counter_increment(publication->short_sends_counter, 1);
}
}

if (0 <= (result = aeron_network_publication_do_send(publication, &iov, 1, &bytes_sent)))
{
result = (int)bytes_sent;
if (bytes_sent < (int64_t)iov.iov_len)
{
aeron_counter_increment(publication->short_sends_counter, 1);
}
}

I'm happy to submit a patch for this, but I'd appreciate guidance on the preferred approach to fixing it. Threading errno through the relevant functions, e.g.

aeron_network_publication_setup_message_check
aeron_network_publication_do_send
aeron_send_channel_send
aeron_udp_channel_transport_send
aeron_udp_channel_transport_send_connected
aeron_send

will break many function signatures, and changing the semantics of the send and receive return codes is similarly evasive. Checking errno at the caller as part of the guard clauses around calls to aeron_counter_get(*->short_sends_counter) would work, as I don't see anything in the call stack clobbering errno, but it's a little fragile. Reclassifying short sends as 0 <= result && bytes_sent > 0 && bytes_sent < (int64_t)iov.iov_len would work, but trade false positives for false negatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0