Skip to content

Commit

Permalink
Fixed attach to OpenJ9 on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
apangin committed Aug 30, 2023
1 parent 77a308a commit e79c44e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/jattach/jattach_openj9.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ static int create_attach_socket(int* port) {
// Try IPv6 socket first, then fall back to IPv4
int s = socket(AF_INET6, SOCK_STREAM, 0);
if (s != -1) {
struct sockaddr_in6 addr = {AF_INET6, 0};
struct sockaddr_in6 addr = {0};
addr.sin6_family = AF_INET6;
socklen_t addrlen = sizeof(addr);
if (bind(s, (struct sockaddr*)&addr, addrlen) == 0 && listen(s, 0) == 0
&& getsockname(s, (struct sockaddr*)&addr, &addrlen) == 0) {
*port = ntohs(addr.sin6_port);
return s;
}
} else if ((s = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
struct sockaddr_in addr = {AF_INET, 0};
struct sockaddr_in addr = {0};
addr.sin_family = AF_INET;
socklen_t addrlen = sizeof(addr);
if (bind(s, (struct sockaddr*)&addr, addrlen) == 0 && listen(s, 0) == 0
&& getsockname(s, (struct sockaddr*)&addr, &addrlen) == 0) {
Expand Down

0 comments on commit e79c44e

Please sign in to comment.