Skip to content

close of closed or faulty connection causes assertion failure #142

@CuriousGeorgiy

Description

@CuriousGeorgiy

Consider this trivial snippet:

#include "../src/Client/Connector.hpp"

using Buf_t = tnt::Buffer<16 * 1024>;
using Net_t = LibevNetProvider<Buf_t, DefaultStream>;

int
main()
{
	Connector<Buf_t, Net_t> client;
	Connection<Buf_t, Net_t> conn(client);
	client.close(conn);
}

It crashes with the following assertion:

Assertion failed: (!conn.strm.has_status(SS_DEAD)), function close, file Connector.hpp, line 171.

However, the SS_DEAD status can be set for a multitude of reasons without the connection being closed or connected. For instance, if the connection was lost or a send/recv failed:

ssize_t rcvd = recvmsg(get_fd(), &msg, flags);
if (rcvd > 0)
return rcvd;
else if (rcvd == 0)
return US_DIE("Peer shutdown");

return US_DIE("Send failed", strerror(errno));

Metadata

Metadata

Labels

bugSomething isn't workingcrash

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions