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

Function createSentinelAddr

app/redis-6.2.6/src/sentinel.c:599–617  ·  view source on GitHub ↗

Create a sentinelAddr object and return it on success. * On error NULL is returned and errno is set to: * ENOENT: Can't resolve the hostname. * EINVAL: Invalid port number. */

Source from the content-addressed store, hash-verified

597 * EINVAL: Invalid port number.
598 */
599sentinelAddr *createSentinelAddr(char *hostname, int port) {
600 char ip[NET_IP_STR_LEN];
601 sentinelAddr *sa;
602
603 if (port < 0 || port > 65535) {
604 errno = EINVAL;
605 return NULL;
606 }
607 if (anetResolve(NULL,hostname,ip,sizeof(ip),
608 sentinel.resolve_hostnames ? ANET_NONE : ANET_IP_ONLY) == ANET_ERR) {
609 errno = ENOENT;
610 return NULL;
611 }
612 sa = zmalloc(sizeof(*sa));
613 sa->hostname = sdsnew(hostname);
614 sa->ip = sdsnew(ip);
615 sa->port = port;
616 return sa;
617}
618
619/* Return a duplicate of the source address. */
620sentinelAddr *dupSentinelAddr(sentinelAddr *src) {

Calls 3

anetResolveFunction · 0.85
zmallocFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected