When sending data on framed UDP channels, if there is a partial frame in
the send buffer waiting to be flushed after the flush timer expires, this
data was added by the application thread. The MeshLink thread does not know
that a timer was updated, and might use an old timeout value and not
respond in time. So if we detect that this might happen, we signal the
MeshLink thread so it can calculate a new timeout and call select() again.
meshlink_errno = MESHLINK_ENETWORK;
}
meshlink_errno = MESHLINK_ENETWORK;
}
+ if(utcp_get_flush_needed(channel->c)) {
+ signal_trigger(&mesh->loop, &mesh->datafromapp);
+ }
+
if(sent_packet) {
if(left) {
// We sent one packet but we have partial data left, (re)start the flush timer
if(sent_packet) {
if(left) {
// We sent one packet but we have partial data left, (re)start the flush timer
+ if(!timespec_isset(&c->rtrx_timeout)) {
+ c->flush_needed = true;
+ }
+
start_flush_timer(c);
} else {
// There is no partial data in the send buffer, so stop the flush timer
start_flush_timer(c);
} else {
// There is no partial data in the send buffer, so stop the flush timer
}
} else if(left && !timespec_isset(&c->rtrx_timeout)) {
// We have partial data and we didn't start the flush timer yet
}
} else if(left && !timespec_isset(&c->rtrx_timeout)) {
// We have partial data and we didn't start the flush timer yet
+ c->flush_needed = true;
start_flush_timer(c);
}
}
start_flush_timer(c);
}
}
void utcp_set_flush_timeout(struct utcp *utcp, int milliseconds) {
utcp->flush_timeout = milliseconds;
}
void utcp_set_flush_timeout(struct utcp *utcp, int milliseconds) {
utcp->flush_timeout = milliseconds;
}
+
+bool utcp_get_flush_needed(struct utcp_connection *c) {
+ bool value = c->flush_needed;
+ c->flush_needed = false;
+ return value;
+}
int utcp_get_flush_timeout(struct utcp *utcp);
void utcp_set_flush_timeout(struct utcp *utcp, int milliseconds);
int utcp_get_flush_timeout(struct utcp *utcp);
void utcp_set_flush_timeout(struct utcp *utcp, int milliseconds);
+bool utcp_get_flush_needed(struct utcp_connection *connection);
uint16_t utcp_get_mtu(struct utcp *utcp);
uint16_t utcp_get_mss(struct utcp *utcp);
uint16_t utcp_get_mtu(struct utcp *utcp);
uint16_t utcp_get_mss(struct utcp *utcp);
bool reapable;
bool do_poll;
bool reapable;
bool do_poll;