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

Commit 4bef08a9 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8972261 from aacf200c to mainline-media-swcodec-release

Change-Id: Ia38dfecd86ff9f799857c8d067567abc7c5d5896
parents d0fede0f aacf200c
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -681,9 +681,9 @@ DnsProxyListener::GetAddrInfoHandler::GetAddrInfoHandler(SocketClient* c, std::s
                                                         std::unique_ptr<addrinfo> hints,
                                                         std::unique_ptr<addrinfo> hints,
                                                         const android_net_context& netcontext)
                                                         const android_net_context& netcontext)
    : Handler(c),
    : Handler(c),
      mHost(move(host)),
      mHost(std::move(host)),
      mService(move(service)),
      mService(std::move(service)),
      mHints(move(hints)),
      mHints(std::move(hints)),
      mNetContext(netcontext) {}
      mNetContext(netcontext) {}


static bool evaluate_domain_name(const android_net_context& netcontext, const char* host) {
static bool evaluate_domain_name(const android_net_context& netcontext, const char* host) {
@@ -954,7 +954,7 @@ int DnsProxyListener::GetAddrInfoCmd::runCommand(SocketClient* cli, int argc, ch
        hints->ai_protocol = ai_protocol;
        hints->ai_protocol = ai_protocol;
    }
    }


    (new GetAddrInfoHandler(cli, name, service, move(hints), netcontext))->spawn();
    (new GetAddrInfoHandler(cli, name, service, std::move(hints), netcontext))->spawn();
    return 0;
    return 0;
}
}


@@ -1202,7 +1202,7 @@ int DnsProxyListener::GetHostByNameCmd::runCommand(SocketClient* cli, int argc,
DnsProxyListener::GetHostByNameHandler::GetHostByNameHandler(SocketClient* c, std::string name,
DnsProxyListener::GetHostByNameHandler::GetHostByNameHandler(SocketClient* c, std::string name,
                                                             int af,
                                                             int af,
                                                             const android_net_context& netcontext)
                                                             const android_net_context& netcontext)
    : Handler(c), mName(move(name)), mAf(af), mNetContext(netcontext) {}
    : Handler(c), mName(std::move(name)), mAf(af), mNetContext(netcontext) {}


void DnsProxyListener::GetHostByNameHandler::doDns64Synthesis(int32_t* rv, hostent* hbuf, char* buf,
void DnsProxyListener::GetHostByNameHandler::doDns64Synthesis(int32_t* rv, hostent* hbuf, char* buf,
                                                              size_t buflen, struct hostent** hpp,
                                                              size_t buflen, struct hostent** hpp,
+1 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ class Experiments {
            "dot_validation_latency_offset_ms",
            "dot_validation_latency_offset_ms",
            "dot_xport_unusable_threshold",
            "dot_xport_unusable_threshold",
            "keep_listening_udp",
            "keep_listening_udp",
            "max_cache_entries",
            "max_queries_global",
            "max_queries_global",
            "mdns_resolution",
            "mdns_resolution",
            "parallel_lookup_release",
            "parallel_lookup_release",
+1 −0
Original line number Original line Diff line number Diff line
@@ -1792,6 +1792,7 @@ static int res_searchN(const char* name, res_target* target, ResState* res, int*


    hp = (HEADER*)(void*)target->answer.data();
    hp = (HEADER*)(void*)target->answer.data();


    errno = 0;
    *herrno = HOST_NOT_FOUND; /* default, if we never query */
    *herrno = HOST_NOT_FOUND; /* default, if we never query */
    dots = 0;
    dots = 0;
    for (cp = name; *cp; cp++) dots += (*cp == '.');
    for (cp = name; *cp; cp++) dots += (*cp == '.');
+35 −7
Original line number Original line Diff line number Diff line
@@ -153,7 +153,8 @@ using std::span;
 * * Upping by another 5x for the centralized nature
 * * Upping by another 5x for the centralized nature
 * *****************************************
 * *****************************************
 */
 */
const int CONFIG_MAX_ENTRIES = 64 * 2 * 5;
const int MAX_ENTRIES_DEFAULT = 64 * 2 * 5;
const int MAX_ENTRIES_UPPER_BOUND = 100 * 1000;
constexpr int DNSEVENT_SUBSAMPLING_MAP_DEFAULT_KEY = -1;
constexpr int DNSEVENT_SUBSAMPLING_MAP_DEFAULT_KEY = -1;


static time_t _time_now(void) {
static time_t _time_now(void) {
@@ -947,14 +948,14 @@ std::unordered_map<int, uint32_t> resolv_get_dns_event_subsampling_map(bool isMd
//
//
// TODO: move all cache manipulation code here and make data members private.
// TODO: move all cache manipulation code here and make data members private.
struct Cache {
struct Cache {
    Cache() {
    Cache() : max_cache_entries(get_max_cache_entries_from_flag()) {
        entries.resize(CONFIG_MAX_ENTRIES);
        entries.resize(max_cache_entries);
        mru_list.mru_prev = mru_list.mru_next = &mru_list;
        mru_list.mru_prev = mru_list.mru_next = &mru_list;
    }
    }
    ~Cache() { flush(); }
    ~Cache() { flush(); }


    void flush() {
    void flush() {
        for (int nn = 0; nn < CONFIG_MAX_ENTRIES; nn++) {
        for (int nn = 0; nn < max_cache_entries; nn++) {
            Entry** pnode = (Entry**)&entries[nn];
            Entry** pnode = (Entry**)&entries[nn];


            while (*pnode) {
            while (*pnode) {
@@ -985,6 +986,8 @@ struct Cache {
        cv.notify_all();
        cv.notify_all();
    }
    }


    int get_max_cache_entries() { return max_cache_entries; }

    int num_entries = 0;
    int num_entries = 0;


    // TODO: convert to std::list
    // TODO: convert to std::list
@@ -997,6 +1000,21 @@ struct Cache {
        unsigned int hash;
        unsigned int hash;
        struct pending_req_info* next;
        struct pending_req_info* next;
    } pending_requests{};
    } pending_requests{};

  private:
    int get_max_cache_entries_from_flag() {
        int entries = android::net::Experiments::getInstance()->getFlag("max_cache_entries",
                                                                        MAX_ENTRIES_DEFAULT);
        // Check both lower and upper bounds to prevent irrational values mistakenly pushed by
        // server.
        if (entries < MAX_ENTRIES_DEFAULT || entries > MAX_ENTRIES_UPPER_BOUND) {
            LOG(ERROR) << "Misconfiguration on max_cache_entries " << entries;
            entries = MAX_ENTRIES_DEFAULT;
        }
        return entries;
    }

    const int max_cache_entries;
};
};


struct NetConfig {
struct NetConfig {
@@ -1139,7 +1157,7 @@ static void cache_dump_mru_locked(Cache* cache) {
 * table.
 * table.
 */
 */
static Entry** _cache_lookup_p(Cache* cache, Entry* key) {
static Entry** _cache_lookup_p(Cache* cache, Entry* key) {
    int index = key->hash % CONFIG_MAX_ENTRIES;
    int index = key->hash % cache->get_max_cache_entries();
    Entry** pnode = (Entry**) &cache->entries[index];
    Entry** pnode = (Entry**) &cache->entries[index];


    while (*pnode != NULL) {
    while (*pnode != NULL) {
@@ -1355,9 +1373,9 @@ int resolv_cache_add(unsigned netid, span<const uint8_t> query, span<const uint8
        return -EEXIST;
        return -EEXIST;
    }
    }


    if (cache->num_entries >= CONFIG_MAX_ENTRIES) {
    if (cache->num_entries >= cache->get_max_cache_entries()) {
        _cache_remove_expired(cache);
        _cache_remove_expired(cache);
        if (cache->num_entries >= CONFIG_MAX_ENTRIES) {
        if (cache->num_entries >= cache->get_max_cache_entries()) {
            _cache_remove_oldest(cache);
            _cache_remove_oldest(cache);
        }
        }
        // TODO: It looks useless, remove below code after having test to prove it.
        // TODO: It looks useless, remove below code after having test to prove it.
@@ -2074,3 +2092,13 @@ void resolv_netconfig_dump(DumpWriter& dw, unsigned netid) {
        dw.println("TransportType: %s", transport_type_to_str(info->transportTypes));
        dw.println("TransportType: %s", transport_type_to_str(info->transportTypes));
    }
    }
}
}

int resolv_get_max_cache_entries(unsigned netid) {
    std::lock_guard guard(cache_mutex);
    NetConfig* info = find_netconfig_locked(netid);
    if (!info) {
        LOG(WARNING) << __func__ << ": NetConfig for netid " << netid << " not found";
        return -1;
    }
    return info->cache->get_max_cache_entries();
}
 No newline at end of file
+1 −0
Original line number Original line Diff line number Diff line
@@ -211,6 +211,7 @@ int res_nsearch(ResState* statp, const char* name, /* domain name */
    int got_nodata = 0, got_servfail = 0, root_on_list = 0;
    int got_nodata = 0, got_servfail = 0, root_on_list = 0;
    int tried_as_is = 0;
    int tried_as_is = 0;


    errno = 0;
    *herrno = HOST_NOT_FOUND; /* True if we never query. */
    *herrno = HOST_NOT_FOUND; /* True if we never query. */


    dots = 0;
    dots = 0;
Loading