X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Faddress_cache.c;h=b6d48d02be12485466b60815bc29e3e7dc164018;hb=f8190b7233871b5b47c3fc8846731d1bbdef78a5;hp=389615ea68bd3891c2939b89714cfe615a02eef3;hpb=63fbaf7b4a33d5657cd3338b7ea91a173b9973fb;p=tinc diff --git a/src/address_cache.c b/src/address_cache.c index 389615ea..b6d48d02 100644 --- a/src/address_cache.c +++ b/src/address_cache.c @@ -108,7 +108,6 @@ void add_recent_address(address_cache_t *cache, const sockaddr_t *sa) { FILE *fp = fopen(fname, "wb"); if(fp) { - fprintf(stderr, "Writing cache to %s\n", fname); fwrite(&cache->data, sizeof(cache->data), 1, fp); fclose(fp); } @@ -152,7 +151,7 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) { cache->cfg = lookup_config(cache->config_tree, "Address"); } - while(cache->cfg && !cache->ai) { + while(cache->cfg && !cache->aip) { char *address, *port; get_config_string(cache->cfg, &address); @@ -168,6 +167,10 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) { } } + if(cache->ai) { + free_known_addresses(cache->ai); + } + cache->aip = cache->ai = str2addrinfo(address, port, SOCK_STREAM); if(cache->ai) {