diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-25 01:51:36 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-25 01:51:36 +0200 |
commit | 5adfca9b651e0e383d463da9e8158e75cad8e7c7 (patch) | |
tree | 906d85ae42ceede085d7c84bf9cdd9e678c03ae7 /src/resolve.c | |
parent | 482ddc46a62b9a6b8bd615fd35b2bac6d3b7d841 (diff) | |
download | fastd-5adfca9b651e0e383d463da9e8158e75cad8e7c7.tar fastd-5adfca9b651e0e383d463da9e8158e75cad8e7c7.zip |
Remove ref-counting on remotes
Now that peers have a peer id we can use that to specify a peer in a resolve
return. As the remote list of a peer doesn't change without the peer id
changing, instead of taking a remote ref we can just use the peer id and remote
index.
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/resolve.c b/src/resolve.c index e791687..7c512ee 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -33,7 +33,8 @@ typedef struct resolv_arg { - fastd_remote_t *remote; + uint64_t peer_id; + size_t remote; char *hostname; fastd_peer_address_t constraints; } resolv_arg_t; @@ -71,6 +72,7 @@ static void* resolve_peer(void *varg) { uint8_t retbuf[sizeof(fastd_async_resolve_return_t) + n_addr*sizeof(fastd_peer_address_t)] __attribute__((aligned(8))); fastd_async_resolve_return_t *ret = (fastd_async_resolve_return_t*)retbuf; + ret->peer_id = arg->peer_id; ret->remote = arg->remote; if (n_addr) { @@ -107,11 +109,6 @@ void fastd_resolve_peer(fastd_peer_t *peer, fastd_remote_t *remote) { if (!peer->config) exit_bug("trying to resolve temporary peer"); - if (remote->resolving) { - pr_debug("not resolving %P as there is already a resolve running", peer); - return; - } - if (!fastd_timed_out(&remote->last_resolve_timeout)) { /* last resolve was just a few seconds ago */ return; @@ -119,13 +116,12 @@ void fastd_resolve_peer(fastd_peer_t *peer, fastd_remote_t *remote) { pr_verbose("resolving host `%s' for peer %P...", remote->config->hostname, peer); - fastd_remote_ref(remote); remote->last_resolve_timeout = fastd_in_seconds(conf.min_resolve_interval); - remote->resolving = true; resolv_arg_t *arg = malloc(sizeof(resolv_arg_t)); - arg->remote = remote; + arg->peer_id = peer->id; + arg->remote = remote - VECTOR_DATA(peer->remotes); arg->hostname = strdup(remote->config->hostname); arg->constraints = remote->config->address; |