From: Yu Watanabe Date: Mon, 2 Sep 2024 04:06:54 +0000 (+0900) Subject: network/tclass: skip requesting tclass if it is already requested X-Git-Tag: v257-rc1~561^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3f91033aea354c28011e841b7043549a1a5226b;p=thirdparty%2Fsystemd.git network/tclass: skip requesting tclass if it is already requested --- diff --git a/src/network/tc/tclass.c b/src/network/tc/tclass.c index 168d93e1c52..926ec69adf0 100644 --- a/src/network/tc/tclass.c +++ b/src/network/tc/tclass.c @@ -208,6 +208,30 @@ static int tclass_get(Link *link, const TClass *in, TClass **ret) { return 0; } +static int tclass_get_request(Link *link, const TClass *tclass, Request **ret) { + Request *req; + + assert(link); + assert(link->manager); + assert(tclass); + + req = ordered_set_get( + link->manager->request_queue, + &(Request) { + .link = link, + .type = REQUEST_TYPE_TC_CLASS, + .userdata = (void*) tclass, + .hash_func = (hash_func_t) tclass_hash_func, + .compare_func = (compare_func_t) tclass_compare_func, + }); + if (!req) + return -ENOENT; + + if (ret) + *ret = req; + return 0; +} + static int tclass_attach(Link *link, TClass *tclass) { int r; @@ -435,6 +459,9 @@ int link_request_tclass(Link *link, TClass *tclass) { assert(link); assert(tclass); + if (tclass_get_request(link, tclass, NULL) >= 0) + return 0; /* already requested, skipping. */ + if (tclass_get(link, tclass, &existing) < 0) { _cleanup_(tclass_unrefp) TClass *tmp = NULL;