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

Function sendCommandArgv

app/redis-6.2.6/src/replication.c:1985–2005  ·  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

1983 * operation. On error the first byte is a "-".
1984 */
1985char *sendCommandArgv(connection *conn, int argc, char **argv, size_t *argv_lens) {
1986 sds cmd = sdsempty();
1987 char *arg;
1988 int i;
1989
1990 /* Create the command to send to the master. */
1991 cmd = sdscatfmt(cmd,"*%i\r\n",argc);
1992 for (i=0; i<argc; i++) {
1993 int len;
1994 arg = argv[i];
1995 len = argv_lens ? argv_lens[i] : strlen(arg);
1996 cmd = sdscatfmt(cmd,"$%i\r\n",len);
1997 cmd = sdscatlen(cmd,arg,len);
1998 cmd = sdscatlen(cmd,"\r\n",2);
1999 }
2000 char* err = sendCommandRaw(conn, cmd);
2001 sdsfree(cmd);
2002 if (err)
2003 return err;
2004 return NULL;
2005}
2006
2007/* Try a partial resynchronization with the master if we are about to reconnect.
2008 * 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