- if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) {
- logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
+static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgoing) {
+ (void)mesh;
+
+ bool start = false;
+
+ if(outgoing->state == OUTGOING_START) {
+ start = true;
+ outgoing->state = OUTGOING_CANONICAL_RESOLVE;
+ }
+
+ if(outgoing->state == OUTGOING_CANONICAL_RESOLVE) {
+ node_t *n = outgoing->node;
+
+ if(n->canonical_address) {
+ char *address = xstrdup(n->canonical_address);
+ char *port = strchr(address, ' ');
+
+ if(port) {
+ *port++ = 0;
+ port = xstrdup(port);
+ adns_queue(mesh, address, port, canonical_resolve_cb, outgoing->node, 2);
+ return false;
+ } else {
+ logger(mesh, MESHLINK_ERROR, "Canonical address for %s is missing port number", n->name);
+ free(address);
+ outgoing->state = OUTGOING_RECENT;
+ }
+
+ } else {
+ outgoing->state = OUTGOING_RECENT;