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

Function configSetCommand

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

Source from the content-addressed store, hash-verified

711#define config_set_else } else
712
713void configSetCommand(client *c) {
714 robj *o;
715 long long ll;
716 int err;
717 const char *errstr = NULL;
718 serverAssertWithInfo(c,c->argv[2],sdsEncodedObject(c->argv[2]));
719 serverAssertWithInfo(c,c->argv[3],sdsEncodedObject(c->argv[3]));
720 o = c->argv[3];
721
722 /* Iterate the configs that are standard */
723 for (standardConfig *config = configs; config->name != NULL; config++) {
724 if (!(config->flags & IMMUTABLE_CONFIG) &&
725 (!strcasecmp(c->argv[2]->ptr,config->name) ||
726 (config->alias && !strcasecmp(c->argv[2]->ptr,config->alias))))
727 {
728 if (config->flags & SENSITIVE_CONFIG) {
729 redactClientCommandArgument(c,3);
730 }
731 if (!config->interface.set(config->data,o->ptr,1,&errstr)) {
732 goto badfmt;
733 }
734 addReply(c,shared.ok);
735 return;
736 }
737 }
738
739 if (0) { /* this starts the config_set macros else-if chain. */
740
741 /* Special fields that can't be handled with general macros. */
742 config_set_special_field("bind") {
743 int vlen;
744 sds *v = sdssplitlen(o->ptr,sdslen(o->ptr)," ",1,&vlen);
745
746 if (vlen < 1 || vlen > CONFIG_BINDADDR_MAX) {
747 addReplyError(c, "Too many bind addresses specified.");
748 sdsfreesplitres(v, vlen);
749 return;
750 }
751
752 if (changeBindAddr(v, vlen) == C_ERR) {
753 addReplyError(c, "Failed to bind to specified addresses.");
754 sdsfreesplitres(v, vlen);
755 return;
756 }
757 sdsfreesplitres(v, vlen);
758 } config_set_special_field("save") {
759 int vlen, j;
760 sds *v = sdssplitlen(o->ptr,sdslen(o->ptr)," ",1,&vlen);
761
762 /* Perform sanity check before setting the new config:
763 * - Even number of args
764 * - Seconds >= 1, changes >= 0 */
765 if (vlen & 1) {
766 sdsfreesplitres(v,vlen);
767 goto badfmt;
768 }
769 for (j = 0; j < vlen; j++) {
770 char *eptr;

Callers 1

configCommandFunction · 0.85

Calls 15

strcasecmpFunction · 0.85
addReplyFunction · 0.85
sdssplitlenFunction · 0.85
sdslenFunction · 0.85
addReplyErrorFunction · 0.85
sdsfreesplitresFunction · 0.85
changeBindAddrFunction · 0.85
resetServerSaveParamsFunction · 0.85
appendServerSaveParamsFunction · 0.85
addReplyErrorFormatFunction · 0.85
getClientTypeByNameFunction · 0.85

Tested by

no test coverage detected