Skip to content

Commit

Permalink
Update address_cache.c
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Jun 10, 2023
1 parent 7ac6ec8 commit 96dfc7b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/address_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ void add_recent_address(address_cache_t *cache, const sockaddr_t *sa) {
}

const sockaddr_t *get_recent_address(address_cache_t *cache) {
struct addrinfo *aip;

// Check if there is an address in our cache of recently seen addresses
if(cache->tried < cache->data.used) {
return &cache->data.address[cache->tried++];
Expand Down Expand Up @@ -324,11 +326,13 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) {
}
}

if(cache->ai) {
aip = resolve_str2addrinfo(address, port, SOCK_STREAM);

if(aip != NULL) {
free_known_addresses(cache->ai);
}

cache->aip = cache->ai = resolve_str2addrinfo(address, port, SOCK_STREAM);
cache->aip = cache->ai = aip;

if(cache->ai) {
struct addrinfo *ai = NULL;
Expand Down

0 comments on commit 96dfc7b

Please sign in to comment.