[systemd-devel] [RFC] socket-proxyd: resolve addrinfo using sd-resolve

Lennart Poettering lennart at poettering.net
Thu Feb 20 18:25:05 PST 2014


On Thu, 20.02.14 21:11, Daniel Buch (boogiewasthere at gmail.com) wrote:

>  
>                  log_debug("Looking up address info for %s:%s", node, service);
> -                r = getaddrinfo(node, service, &hints, &result);
> -                if (r != 0) {
> +                r = sd_resolve_getaddrinfo(resolve, &q, node, service, &hints);
> +                if (r < 0)
> +                        log_error("Error: %s %d\n", gai_strerror(r), r);
> +
> +                while (!sd_resolve_is_done(q)) {
> +                        r = sd_resolve_wait(resolve, (uint64_t) -1);
> +                        if (r < 0) {
> +                                log_error("Error: %s\n", strerror(-r));
> +                                assert_not_reached("sd_resolve_wait() failed");
> +                        }
> +                }
> +
> +                r = sd_resolve_getaddrinfo_done(q, &result);
> +                if (r < 0) {
>                          log_error("Failed to resolve host %s:%s: %s", node, service, gai_strerror(r));
>                          return -EHOSTUNREACH;
>                  }

Yupp, as David already pointed out, this takes the async API and makes
it sync again...

I figure before we can implement this part in the socket proxy we need
to enhance sd-resolve to provide hooks into the event loop. And that
probably means we also need to teach it callbacks... 

So I figure this is a bit more difficult to do...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list