提交 5b7c1613 编写于 作者: A antirez

anetTcpGenericConnect() bug introduced in 9d199770 fixed.

Durign a refactoring I mispelled _port for port.
This is one of the reasons I never used _varname myself.
上级 d07d4a87
......@@ -220,15 +220,15 @@ static int anetCreateSocket(char *err, int domain) {
static int anetTcpGenericConnect(char *err, char *addr, int port, int flags)
{
int s = ANET_ERR, rv;
char _port[6]; /* strlen("65535") + 1; */
char portstr[6]; /* strlen("65535") + 1; */
struct addrinfo hints, *servinfo, *p;
snprintf(_port,sizeof(port),"%d",port);
snprintf(portstr,sizeof(portstr),"%d",port);
memset(&hints,0,sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ((rv = getaddrinfo(addr,_port,&hints,&servinfo)) != 0) {
if ((rv = getaddrinfo(addr,portstr,&hints,&servinfo)) != 0) {
anetSetError(err, "%s", gai_strerror(rv));
return ANET_ERR;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册