On Sun, 20 Oct 2024 04:59:10 +0200,
Brad Smith <b...@comstyle.com> wrote:
> 
> Seeing as the PR is a bunch of fixes, either way put a brief description
> at the top of the patch. You might want to look at updating the comment
> at the very top of lib/net.c to include OpenBSD.

I am not sure if it is a good idea to patch comments inside ports patches.

But I definitely agree that it is a good idea to add some explanation to the
patch, see updated diff.

>       for (try = 0;;) {
>               fd = net_connect_ip_once(ip, port, my_ip, sock_type, blocking);
>               if (fd != -1 || try++ >= MAX_CONNECT_RETRIES ||
>                   (errno != EADDRNOTAVAIL
> #if defined(__FreeBSD__) || defined(__OpenBSD__)
>                    /* busy */
>                    && errno != EADDRINUSE
>                    /* pf may cause this if another connection used
>                       the same port recently */
>                    && errno != EACCES
> #endif
>                   ))
> 
> 
> I am not sure what is considered normal and appropriate for userland
> network and PF. I guess I'd be Ok if someone else more familiar with
> these kinds of bits said this is appropriate.

Neither do I, but this patch seems to cover errors which I see from time to
time, and based on the fact that such logic exists, I really think that this
is what the authors of dovecot meant. And if this logic/behavior is wrong,
it probably should be addressed upstream.

Anyway, updated diff:

Index: Makefile
===================================================================
RCS file: /cvs/ports/mail/dovecot/Makefile,v
retrieving revision 1.319
diff -u -p -r1.319 Makefile
--- Makefile    5 Oct 2024 07:35:54 -0000       1.319
+++ Makefile    20 Oct 2024 08:15:20 -0000
@@ -11,7 +11,7 @@ COMMENT-postgresql= PostgreSQL authentic
 V_MAJOR=       2.3
 V_DOVECOT=     2.3.21.1
 EPOCH=         0
-REVISION=      0
+REVISION=      1
 
 DISTNAME=      dovecot-${V_DOVECOT}
 PKGNAME=       dovecot-${V_DOVECOT}
Index: patches/patch-src_lib_net_c
===================================================================
RCS file: patches/patch-src_lib_net_c
diff -N patches/patch-src_lib_net_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lib_net_c 20 Oct 2024 08:15:20 -0000
@@ -0,0 +1,20 @@
+net: OpenBSD should behave like FreeBSD on net_connect_ip_full
+
+This patch fixes errors such as
+ 
+      Fatal: connect(...) failed: Address already in use
+ 
+The fix is simple, extending FreeBSD's condition to OpenBSD as well,
+which results in such errors disappearing on the tested setup.
+Index: src/lib/net.c
+--- src/lib/net.c.orig
++++ src/lib/net.c
+@@ -213,7 +213,7 @@ static int net_connect_ip_full(const struct ip_addr *i
+               fd = net_connect_ip_once(ip, port, my_ip, sock_type, blocking);
+               if (fd != -1 || try++ >= MAX_CONNECT_RETRIES ||
+                   (errno != EADDRNOTAVAIL
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__OpenBSD__)
+                    /* busy */
+                    && errno != EADDRINUSE
+                    /* pf may cause this if another connection used


-- 
wbr, Kirill

Reply via email to