Address caches are associated with nodes, so just use the address cache
in the node_t struct. Also ensure we always have opened an address cache in
setup_outgoing_connection().
Thanks to admincheg for finding this issue.
typedef struct outgoing_t {
struct node_t *node;
int timeout;
typedef struct outgoing_t {
struct node_t *node;
int timeout;
- struct address_cache_t *address_cache;
timeout_t ev;
} outgoing_t;
timeout_t ev;
} outgoing_t;
- sa = get_recent_address(outgoing->address_cache);
+ sa = get_recent_address(outgoing->node->address_cache);
if(!sa) {
logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not set up a meta connection to %s", outgoing->node->name);
if(!sa) {
logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not set up a meta connection to %s", outgoing->node->name);
node_t *n = outgoing->node;
node_t *n = outgoing->node;
+ if(!n->address_cache) {
+ n->address_cache = open_address_cache(n);
+ }
+
if(n->connection) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Already connected to %s", n->name);
if(n->connection) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Already connected to %s", n->name);
- if(!outgoing->address_cache) {
- outgoing->address_cache = open_address_cache(n);
- }
-
do_outgoing_connection(outgoing);
return;
do_outgoing_connection(outgoing);
return;
static void free_outgoing(outgoing_t *outgoing) {
timeout_del(&outgoing->ev);
static void free_outgoing(outgoing_t *outgoing) {
timeout_del(&outgoing->ev);
-
- if(outgoing->address_cache) {
- close_address_cache(outgoing->address_cache);
- }
-
/* Successful connection, reset timeout if this is an outgoing connection. */
/* Successful connection, reset timeout if this is an outgoing connection. */
+ if(c->outgoing && c->outgoing->timeout) {
c->outgoing->timeout = 0;
c->outgoing->timeout = 0;
- reset_address_cache(c->outgoing->address_cache, &c->address);
+ reset_address_cache(c->outgoing->node->address_cache, &c->address);