}
void retry_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) {
- if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[mesh->devclass].fast_retry_period) {
+ if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[outgoing->node->devclass].fast_retry_period) {
outgoing->timeout = 1;
} else {
outgoing->timeout += 5;
}
- if(outgoing->timeout > mesh->maxtimeout) {
- outgoing->timeout = mesh->maxtimeout;
+ int maxtimeout = mesh->dev_class_traits[outgoing->node->devclass].maxtimeout;
+
+ if(outgoing->timeout > maxtimeout) {
+ outgoing->timeout = maxtimeout;
}
timeout_add(&mesh->loop, &outgoing->ev, retry_outgoing_handler, outgoing, &(struct timespec) {
return;
}
+ if(c->node) {
+ c->node->out_meta += outlen;
+ }
+
buffer_read(&c->outbuf, outlen);
if(!c->outbuf.len) {
}
}
+void flush_meta(meshlink_handle_t *mesh, connection_t *c) {
+ handle_meta_write(mesh, c);
+}
+
static void handle_meta_io(event_loop_t *loop, void *data, int flags) {
meshlink_handle_t *mesh = loop->data;
connection_t *c = data;
if(!result) {
finish_connecting(mesh, c);
} else {
- logger(mesh, MESHLINK_DEBUG, "Error while connecting to %s: %s", c->name, sockstrerror(result));
+ logger(mesh, MESHLINK_ERROR, "Error while connecting to %s: %s", c->name, sockstrerror(result));
terminate_connection(mesh, c, false);
return;
}
outgoing->ai = NULL;
outgoing->aip = NULL;
- outgoing->state = OUTGOING_RECENT;
+ outgoing->state = OUTGOING_END;
}
if(outgoing->state == OUTGOING_RECENT) {
/* We are waiting for a callback from the ADNS thread */
} else if(outgoing->state == OUTGOING_NO_KNOWN_ADDRESSES) {
logger(mesh, MESHLINK_ERROR, "No known addresses for %s", outgoing->node->name);
+ list_delete(mesh->outgoings, outgoing);
} else {
logger(mesh, MESHLINK_ERROR, "Could not set up a meta connection to %s", outgoing->node->name);
retry_outgoing(mesh, outgoing);
fd = accept(l->tcp.fd, &sa.sa, &len);
if(fd < 0) {
+ if(sockwouldblock(errno)) {
+ return;
+ }
+
if(errno == EINVAL) { // TODO: check if Windows agrees
event_loop_stop(loop);
return;