Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6efaac1 authored by Ken Chen's avatar Ken Chen
Browse files

Add more traces in error cases

Current logs are unable to tell why mdns fallback doesn't work. Add a
few logs on error paths.

Bug: 226325994
Test: adb locat
Change-Id: Ifd61bbbd61b8866296d7b4583a2d9e78ba43c78d
parent a3b3e886
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1660,7 +1660,8 @@ QueryResult doQuery(const char* name, res_target* t, ResState* res,
        }
        }
    }
    }


    LOG(INFO) << __func__ << ": rcode=" << rcode << ", ancount=" << ntohs(hp->ancount);
    LOG(INFO) << __func__ << ": rcode=" << rcode << ", ancount=" << ntohs(hp->ancount)
              << ", return value=" << n;


    t->n = n;
    t->n = n;
    return {
    return {
+4 −1
Original line number Original line Diff line number Diff line
@@ -1851,7 +1851,10 @@ int resolv_cache_get_resolver_stats(unsigned netid, res_params* params, res_stat
                                    const std::vector<IPSockAddr>& serverSockAddrs) {
                                    const std::vector<IPSockAddr>& serverSockAddrs) {
    std::lock_guard guard(cache_mutex);
    std::lock_guard guard(cache_mutex);
    NetConfig* info = find_netconfig_locked(netid);
    NetConfig* info = find_netconfig_locked(netid);
    if (!info) return -1;
    if (!info) {
        LOG(WARNING) << __func__ << ": NetConfig for netid " << netid << " not found";
        return -1;
    }


    for (size_t i = 0; i < serverSockAddrs.size(); i++) {
    for (size_t i = 0; i < serverSockAddrs.size(); i++) {
        for (size_t j = 0; j < info->nameserverSockAddrs.size(); j++) {
        for (size_t j = 0; j < info->nameserverSockAddrs.size(); j++) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -504,7 +504,7 @@ int res_nsend(ResState* statp, span<const uint8_t> msg, span<uint8_t> ans, int*
        // asking the same question will block for PENDING_REQUEST_TIMEOUT seconds instead
        // asking the same question will block for PENDING_REQUEST_TIMEOUT seconds instead
        // of failing fast.
        // of failing fast.
        _resolv_cache_query_failed(statp->netid, msg, flags);
        _resolv_cache_query_failed(statp->netid, msg, flags);

        LOG(DEBUG) << __func__ << ": no nameserver";
        // TODO: Remove errno once callers stop using it
        // TODO: Remove errno once callers stop using it
        errno = ESRCH;
        errno = ESRCH;
        return -ESRCH;
        return -ESRCH;
@@ -526,6 +526,7 @@ int res_nsend(ResState* statp, span<const uint8_t> msg, span<uint8_t> ans, int*
        }
        }
        if (!fallback) {
        if (!fallback) {
            _resolv_cache_query_failed(statp->netid, msg, flags);
            _resolv_cache_query_failed(statp->netid, msg, flags);
            LOG(DEBUG) << __func__ << ": private DNS failed";
            return -ETIMEDOUT;
            return -ETIMEDOUT;
        }
        }
    }
    }
@@ -540,6 +541,7 @@ int res_nsend(ResState* statp, span<const uint8_t> msg, span<uint8_t> ans, int*
    res_params params;
    res_params params;
    int revision_id = resolv_cache_get_resolver_stats(statp->netid, &params, stats, statp->nsaddrs);
    int revision_id = resolv_cache_get_resolver_stats(statp->netid, &params, stats, statp->nsaddrs);
    if (revision_id < 0) {
    if (revision_id < 0) {
        LOG(ERROR) << __func__ << ": revision_id < 0";
        // TODO: Remove errno once callers stop using it
        // TODO: Remove errno once callers stop using it
        errno = ESRCH;
        errno = ESRCH;
        return -ESRCH;
        return -ESRCH;