void evalName(redisClient *c, char *name) { sds hash; robj *sha; /* if len(name) == 40, then this *could* be a script hash. * Try to look it up as a hash first. */ if (sdslen(name) == 40 && dictFind(server.lua_scripts, name)) { hash = name; } else { hash = dictFetchValue(g.names, name); /* If we didn't find it, or if we did find it but for some * reason the len(hash) != 40, ... */ if (!hash || sdslen(hash) != 40) { addReply(c, g.err.nosha); return; } } /* the redisClient object uses robj * for fields, * so here we convert the sds hash into an robj of * an sds */ sha = createStringObject(hash, sdslen(hash)); rewriteClientCommandArgument(c, 1, sha); decrRefCount(sha); /* No leaking memory from our created robj */ /* Now run the script as normal, just like we never existed. *poof* */ evalGenericCommand(c, 1); }
void evalShaCommand(redisClient *c) { if (sdslen(c->argv[1]->ptr) != 40) { /* We know that a match is not possible if the provided SHA is * not the right length. So we return an error ASAP, this way * evalGenericCommand() can be implemented without string length * sanity check */ addReply(c, shared.noscripterr); return; } evalGenericCommand(c,1); }
void evalShaCommand(rliteClient *c) { if (c->argvlen[1] != 40) { /* We know that a match is not possible if the provided SHA is * not the right length. So we return an error ASAP, this way * evalGenericCommand() can be implemented without string length * sanity check */ c->reply = createErrorObject(RLITE_NOSCRIPTERR); return; } evalGenericCommand(c,1); }
void evalCommand(redisClient *c) { evalGenericCommand(c,0); }
void evalCommand(rliteClient *c) { evalGenericCommand(c,0); }