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
| 1579 | * This function does just this, iterating all the option names and |
| 1580 | * blanking all the lines still associated. */ |
| 1581 | void 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. |
no test coverage detected