librb: set sockaddr port to 0 in success path

Instead of only in the failure path, which causes
all sorts of annoying server connection failures
when we try to repeatedly reuse the same port.
This commit is contained in:
Simon Arlott 2016-09-03 14:36:17 +01:00
parent 94f114641c
commit 1315fd5920
No known key found for this signature in database
GPG Key ID: C8975F2043CA5D24
1 changed files with 2 additions and 1 deletions

View File

@ -1323,6 +1323,7 @@ rb_inet_pton_sock(const char *src, struct sockaddr *dst)
if(rb_inet_pton(AF_INET, src, &((struct sockaddr_in *)dst)->sin_addr))
{
SET_SS_FAMILY(dst, AF_INET);
SET_SS_PORT(dst, 0);
SET_SS_LEN(dst, sizeof(struct sockaddr_in));
return 1;
}
@ -1330,11 +1331,11 @@ rb_inet_pton_sock(const char *src, struct sockaddr *dst)
else if(rb_inet_pton(AF_INET6, src, &((struct sockaddr_in6 *)dst)->sin6_addr))
{
SET_SS_FAMILY(dst, AF_INET6);
SET_SS_PORT(dst, 0);
SET_SS_LEN(dst, sizeof(struct sockaddr_in6));
return 1;
}
#endif
SET_SS_PORT(dst, 0);
return 0;
}