diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-05-03 20:00:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-05-03 20:00:20 +0200 |
commit | 6e39dfe32584e9edaa45d0df31765839dae219c5 (patch) | |
tree | 38760ff8eb30f12b6616c06cefebd77718e37376 /src/resolve.c | |
parent | 1519fd273496e412a3bad908313d5d60cc9f4f57 (diff) | |
download | fastd-6e39dfe32584e9edaa45d0df31765839dae219c5.tar fastd-6e39dfe32584e9edaa45d0df31765839dae219c5.zip |
Use pipe to transmit resolved addresses to main threadv0.4-rc7
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/resolve.c b/src/resolve.c index 23e7f32..6848a11 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -31,7 +31,7 @@ #include <netdb.h> #include <pthread.h> -#include <signal.h> +#include <unistd.h> typedef struct _resolv_arg { @@ -70,25 +70,21 @@ static void* resolve_peer(void *varg) { error = true; } - fastd_resolve_return *ret = malloc(sizeof(fastd_resolve_return)); + fastd_resolve_return ret; - ret->ctx = arg->ctx; - - ret->hostname = arg->hostname; - ret->constraints = arg->constraints; + ret.hostname = arg->hostname; + ret.constraints = arg->constraints; if (!error) { pr_debug(arg->ctx, "Resolved host `%s' successfully", arg->hostname); - memcpy(&ret->addr, res->ai_addr, res->ai_addrlen); + memcpy(&ret.addr, res->ai_addr, res->ai_addrlen); } else { - ret->addr.sa.sa_family = AF_UNSPEC; + ret.addr.sa.sa_family = AF_UNSPEC; } - union sigval sigval; - sigval.sival_ptr = ret; - if (pthread_sigqueue(arg->master_thread, SIGUSR1, sigval)) - exit_errno(arg->ctx, "pthread_sigqueue"); + if (write(arg->ctx->resolvewfd, &ret, sizeof(ret)) < 0) + exit_errno(arg->ctx, "write"); freeaddrinfo(res); free(arg); |