When there is an error that would cause the poll callback to be called
with length zero, make sure we drop the buffers first, so that calls to
meshlink_channel_get_sendq() will also return zero. This allows poll
callbacks that wait for the send buffer to be emptied to work correctly.
// The peer has aborted our connection.
set_state(c, CLOSED);
errno = ECONNRESET;
+ buffer_clear(&c->sndbuf);
+ buffer_clear(&c->rcvbuf);
if(c->recv) {
c->recv(c, NULL, 0);
if(timespec_isset(&c->conn_timeout) && timespec_lt(&c->conn_timeout, &now)) {
errno = ETIMEDOUT;
c->state = CLOSED;
+ buffer_clear(&c->sndbuf);
+ buffer_clear(&c->rcvbuf);
if(c->recv) {
c->recv(c, NULL, 0);
struct utcp_connection *c = utcp->connections[i];
if(!c->reapable) {
+ buffer_clear(&c->sndbuf);
+ buffer_clear(&c->rcvbuf);
+
if(c->recv) {
c->recv(c, NULL, 0);
}