From: Alan T. DeKok Date: Mon, 16 Mar 2026 18:16:39 +0000 (-0400) Subject: cache xlat can succeed if it returns no data. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1af6fcbb6ccf01d69c6aa10cf779eefd802e62ef;p=thirdparty%2Ffreeradius-server.git cache xlat can succeed if it returns no data. i.e. "no data in cache" isn't an xlat failure, it's an xlat success with no data. --- diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index c8b00e8d274..d5089cc293e 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -937,6 +937,11 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, case RLM_MODULE_OK: /* found */ break; + case RLM_MODULE_NOTFOUND: /* !found is "no data" */ + talloc_free(target); + cache_release(inst, request, &handle); + return XLAT_ACTION_DONE; + default: talloc_free(target); cache_release(inst, request, &handle); @@ -966,9 +971,9 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, cache_release(inst, request, &handle); /* - * Check if we found a matching map + * If we found a value, then the output has been updated. + * Otherwise, there is no output. Either way, the xlat succeeded. */ - if (!map) return XLAT_ACTION_FAIL; return XLAT_ACTION_DONE; } diff --git a/src/tests/modules/cache_rbtree/cache-xlat.unlang b/src/tests/modules/cache_rbtree/cache-xlat.unlang index 6787f7c5d52..e711989e36d 100644 --- a/src/tests/modules/cache_rbtree/cache-xlat.unlang +++ b/src/tests/modules/cache_rbtree/cache-xlat.unlang @@ -29,9 +29,31 @@ if (Login-LAT-Node) { # Regression test for deadlock on notfound Filter-Id := 'testkey0' +# +# There is no request.Login-LAT-Port, so the input is empty. +# Login-LAT-Node := %cache(request.Login-LAT-Port) # Would previously deadlock Login-LAT-Port := %cache(request.Login-LAT-Port) +# +# Get the value for a key which doesn't exist. The xlat should succeed, but return no data. +# +Filter-Id := 'nosuchkey' +request.Login-LAT-Service := %cache('request.Callback-Id') +if request.Login-LAT-Service { + test_fail +} + +# +# And then verify that the previous cache entry hasn't been deleted +# +Filter-Id := 'testkey' +request.Login-LAT-Service := %cache('request.Callback-Id') + +if (Login-LAT-Service != control.Callback-Id) { + test_fail +} + test_pass