MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sendCommandArgv

Function sendCommandArgv

src/replication.cpp:3156–3176  ·  view source on GitHub ↗

Compose a multi-bulk command and send it to the connection. * Used to send AUTH and REPLCONF commands to the master before starting the * replication. * * argv_lens is optional, when NULL, strlen is used. * * The command returns an sds string representing the result of the * operation. On error the first byte is a "-". */

Source from the content-addressed store, hash-verified

3154 * operation. On error the first byte is a "-".
3155 */
3156char *sendCommandArgv(connection *conn, int argc, const char **argv, size_t *argv_lens) {
3157 sds cmd = sdsempty();
3158 const char *arg;
3159 int i;
3160
3161 /* Create the command to send to the master. */
3162 cmd = sdscatfmt(cmd,"*%i\r\n",argc);
3163 for (i=0; i<argc; i++) {
3164 int len;
3165 arg = argv[i];
3166 len = argv_lens ? argv_lens[i] : strlen(arg);
3167 cmd = sdscatfmt(cmd,"$%i\r\n",len);
3168 cmd = sdscatlen(cmd,arg,len);
3169 cmd = sdscatlen(cmd,"\r\n",2);
3170 }
3171 char* err = sendCommandRaw(conn, cmd);
3172 sdsfree(cmd);
3173 if (err)
3174 return err;
3175 return NULL;
3176}
3177
3178/* Try a partial resynchronization with the master if we are about to reconnect.
3179 * If there is no cached master structure, at least try to issue a

Callers 1

syncWithMasterFunction · 0.85

Calls 5

sdsemptyFunction · 0.85
sdscatfmtFunction · 0.85
sdscatlenFunction · 0.85
sendCommandRawFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected