MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rewriteConfigRemoveOrphaned

Function rewriteConfigRemoveOrphaned

app/redis-6.2.6/src/config.c:1581–1606  ·  view source on GitHub ↗

At the end of the rewrite process the state contains the remaining * map between "option name" => "lines in the original config file". * Lines used by the rewrite process were removed by the function * rewriteConfigRewriteLine(), all the other lines are "orphaned" and * should be replaced by empty lines. * * This function does just this, iterating all the option names and * blanking all the

Source from the content-addressed store, hash-verified

1579 * This function does just this, iterating all the option names and
1580 * blanking all the lines still associated. */
1581void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
1582 dictIterator *di = dictGetIterator(state->option_to_line);
1583 dictEntry *de;
1584
1585 while((de = dictNext(di)) != NULL) {
1586 list *l = dictGetVal(de);
1587 sds option = dictGetKey(de);
1588
1589 /* Don't blank lines about options the rewrite process
1590 * don't understand. */
1591 if (dictFind(state->rewritten,option) == NULL) {
1592 serverLog(LL_DEBUG,"Not rewritten option: %s", option);
1593 continue;
1594 }
1595
1596 while(listLength(l)) {
1597 listNode *ln = listFirst(l);
1598 int linenum = (long) ln->value;
1599
1600 sdsfree(state->lines[linenum]);
1601 state->lines[linenum] = sdsempty();
1602 listDelNode(l,ln);
1603 }
1604 }
1605 dictReleaseIterator(di);
1606}
1607
1608/* This function replaces the old configuration file with the new content
1609 * in an atomic manner.

Callers 1

rewriteConfigFunction · 0.85

Calls 7

sdsfreeFunction · 0.85
sdsemptyFunction · 0.85
listDelNodeFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictFindFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected