summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorMoti Cohen <moti.cohen@redis.com>2022-04-19 14:22:16 +0300
committerGitHub <noreply@github.com>2022-04-19 14:22:16 +0300
commit295cbf297f3ec1ccb0bb07559bedaf441936d249 (patch)
tree8c9f0ee11bc8b2921bd6110f0f2103a8d9ee85a2 /src/config.c
parentd4cbd8140bb18ccec6af1561f6c2067f8c00a7b0 (diff)
downloadredis-295cbf297f3ec1ccb0bb07559bedaf441936d249.tar.gz
Add comment to sdsConfigSet() (#10605)
Improve comments to explain the code Co-authored-by: moticless <moticless@github.com> Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index cc5a388dc..c4b893c28 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1821,10 +1821,16 @@ static int sdsConfigSet(standardConfig *config, sds *argv, int argc, const char
UNUSED(argc);
if (config->data.sds.is_valid_fn && !config->data.sds.is_valid_fn(argv[0], err))
return 0;
+
sds prev = config->flags & MODULE_CONFIG ? getModuleStringConfig(config->privdata) : *config->data.sds.config;
sds new = (config->data.string.convert_empty_to_null && (sdslen(argv[0]) == 0)) ? NULL : argv[0];
+
+ /* if prev and new configuration are not equal, set the new one */
if (new != prev && (new == NULL || prev == NULL || sdscmp(prev, new))) {
+ /* If MODULE_CONFIG flag is set, then free temporary prev getModuleStringConfig returned.
+ * Otherwise, free the actual previous config value Redis held (Same action, different reasons) */
sdsfree(prev);
+
if (config->flags & MODULE_CONFIG) {
return setModuleStringConfig(config->privdata, new, err);
}