extern void load_all_nodes(struct meshlink_handle *mesh);
extern bool setup_myself_reloadable(struct meshlink_handle *mesh) __attribute__((__warn_unused_result__));
extern bool setup_network(struct meshlink_handle *mesh) __attribute__((__warn_unused_result__));
+extern void reset_outgoing(struct outgoing_t *);
extern void setup_outgoing_connection(struct meshlink_handle *mesh, struct outgoing_t *);
extern void close_network_connections(struct meshlink_handle *mesh);
extern void main_loop(struct meshlink_handle *mesh);
io_add(&mesh->loop, &c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE);
}
+void reset_outgoing(outgoing_t *outgoing) {
+ if(outgoing->ai) {
+ if(outgoing->state == OUTGOING_RECENT || outgoing->state == OUTGOING_KNOWN) {
+ free_known_addresses(outgoing->ai);
+ } else {
+ freeaddrinfo(outgoing->ai);
+ }
+ }
+
+ outgoing->ai = NULL;
+ outgoing->aip = NULL;
+ outgoing->state = OUTGOING_START;
+}
+
void setup_outgoing_connection(meshlink_handle_t *mesh, outgoing_t *outgoing) {
timeout_del(&mesh->loop, &outgoing->ev);
return;
}
-
- if(outgoing->ai) {
- if(outgoing->state == OUTGOING_RECENT || outgoing->state == OUTGOING_KNOWN) {
- free_known_addresses(outgoing->ai);
- } else {
- freeaddrinfo(outgoing->ai);
- }
- }
-
- outgoing->state = OUTGOING_START;
+ reset_outgoing(outgoing);
if(outgoing->node->status.blacklisted) {
return;
/* Successful connection, reset timeout if this is an outgoing connection. */
- // TODO: completely remove this outgoing, let the autoconnect algorithm handle it
if(c->outgoing) {
- c->outgoing->timeout = 0;
- c->outgoing->state = OUTGOING_START;
-
- if(c->outgoing->ai) {
- freeaddrinfo(c->outgoing->ai);
- }
-
- c->outgoing->ai = NULL;
- c->outgoing->aip = NULL;
+ reset_outgoing(c->outgoing);
}
return true;
-Subproject commit 19f3f4462c52eaa766ab76ce671921f0e4dc4ebd
+Subproject commit eb85ec4ae5f32102430e0622e3855aaba110c032