git: 45bed8722929 - main - mail/mlmmj: fix ipv6 support

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Mon, 24 Jan 2022 08:34:23 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=45bed872292949334ac6e47c409002e1f93b1043

commit 45bed872292949334ac6e47c409002e1f93b1043
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-01-24 08:33:32 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-01-24 08:34:13 +0000

    mail/mlmmj: fix ipv6 support
---
 mail/mlmmj/Makefile                       |  2 +-
 mail/mlmmj/files/patch-src_init__sockfd.c | 11 +++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/mail/mlmmj/Makefile b/mail/mlmmj/Makefile
index b8b31051d641..c1655ca42f86 100644
--- a/mail/mlmmj/Makefile
+++ b/mail/mlmmj/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	mlmmj
 PORTVERSION=	1.3.0
-PORTREVISION=	9
+PORTREVISION=	10
 CATEGORIES=	mail
 MASTER_SITES=	http://mlmmj.org/releases/
 
diff --git a/mail/mlmmj/files/patch-src_init__sockfd.c b/mail/mlmmj/files/patch-src_init__sockfd.c
index 5eb98647a35d..009c421a3f84 100644
--- a/mail/mlmmj/files/patch-src_init__sockfd.c
+++ b/mail/mlmmj/files/patch-src_init__sockfd.c
@@ -8,7 +8,7 @@
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <unistd.h>
-@@ -29,35 +30,53 @@
+@@ -29,35 +30,50 @@
  #include <arpa/inet.h>
  #include <string.h>
  #include <inttypes.h>
@@ -32,6 +32,8 @@
  	}
  
 -	*sockfd = socket(PF_INET, SOCK_STREAM, 0);
+-	if(*sockfd == -1) {
+-		log_error(LOG_ARGS, "Could not get socket");
 +	memset(&hints, 0, sizeof(hints));
 +	hints.ai_socktype = SOCK_STREAM;
 +	hints.ai_family = PF_UNSPEC;
@@ -39,10 +41,6 @@
 +	if (getaddrinfo(relayhost, srv, &hints, &ai) != 0) {
 +		log_error(LOG_ARGS, "Unable to lookup for relayhost %s:%s",
 +		    relayhost, srv);
-+		return;
-+	}
- 	if(*sockfd == -1) {
- 		log_error(LOG_ARGS, "Could not get socket");
  		return;
  	}
 -	addr.sin_family = PF_INET;
@@ -50,11 +48,12 @@
 -	addr.sin_port = htons(port);
 -	len = sizeof(addr);
 -	if(connect(*sockfd, (struct sockaddr *)&addr, len) == -1) {
++
 +	for (curai = ai; curai != NULL; curai = curai->ai_next) {
 +		if ((sd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) {
 +			continue;
 +		}
-+		if (connect(sd, ai->ai_addr, ai->ai_addrlen) == 0) {
++		if (connect(sd, ai->ai_addr, ai->ai_addrlen) != 0) {
 +			close(sd);
 +			sd = -1;
 +			continue;