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

Function clusterManagerNodeConnect

app/redis-6.2.6/src/redis-cli.c:2817–2854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2815}
2816
2817static int clusterManagerNodeConnect(clusterManagerNode *node) {
2818 if (node->context) redisFree(node->context);
2819 node->context = redisConnect(node->ip, node->port);
2820 if (!node->context->err && config.tls) {
2821 const char *err = NULL;
2822 if (cliSecureConnection(node->context, config.sslconfig, &err) == REDIS_ERR && err) {
2823 fprintf(stderr,"TLS Error: %s\n", err);
2824 redisFree(node->context);
2825 node->context = NULL;
2826 return 0;
2827 }
2828 }
2829 if (node->context->err) {
2830 fprintf(stderr,"Could not connect to Redis at ");
2831 fprintf(stderr,"%s:%d: %s\n", node->ip, node->port,
2832 node->context->errstr);
2833 redisFree(node->context);
2834 node->context = NULL;
2835 return 0;
2836 }
2837 /* Set aggressive KEEP_ALIVE socket option in the Redis context socket
2838 * in order to prevent timeouts caused by the execution of long
2839 * commands. At the same time this improves the detection of real
2840 * errors. */
2841 anetKeepAlive(NULL, node->context->fd, REDIS_CLI_KEEPALIVE_INTERVAL);
2842 if (config.auth) {
2843 redisReply *reply;
2844 if (config.user == NULL)
2845 reply = redisCommand(node->context,"AUTH %s", config.auth);
2846 else
2847 reply = redisCommand(node->context,"AUTH %s %s",
2848 config.user,config.auth);
2849 int ok = clusterManagerCheckRedisReply(node, reply, NULL);
2850 if (reply != NULL) freeReplyObject(reply);
2851 if (!ok) return 0;
2852 }
2853 return 1;
2854}
2855
2856static void clusterManagerRemoveNodeFromList(list *nodelist,
2857 clusterManagerNode *node) {

Calls 7

redisFreeFunction · 0.85
redisConnectFunction · 0.85
cliSecureConnectionFunction · 0.85
anetKeepAliveFunction · 0.85
freeReplyObjectFunction · 0.85
redisCommandClass · 0.70

Tested by

no test coverage detected