X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/85238765033e2fa89b1879383421d5a8aafff17f..518e7202b29a287f49671fd32f706054570b3f4e:/src/anet.c diff --git a/src/anet.c b/src/anet.c index 9aff4dfa..ba4e6cce 100644 --- a/src/anet.c +++ b/src/anet.c @@ -353,7 +353,12 @@ int anetPeerToString(int fd, char *ip, int *port) { struct sockaddr_in sa; socklen_t salen = sizeof(sa); - if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) return -1; + if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) { + *port = 0; + ip[0] = '?'; + ip[1] = '\0'; + return -1; + } if (ip) strcpy(ip,inet_ntoa(sa.sin_addr)); if (port) *port = ntohs(sa.sin_port); return 0;