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 "-". */
| 1983 | * operation. On error the first byte is a "-". |
| 1984 | */ |
| 1985 | char *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 |
no test coverage detected