dovecot: FreeBSD: If connect() fails with EADDRINUSE or EACCES, ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Nov 29 07:23:53 EET 2007
details: http://hg.dovecot.org/dovecot/rev/ed6693fc06d6
changeset: 6876:ed6693fc06d6
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 29 07:23:48 2007 +0200
description:
FreeBSD: If connect() fails with EADDRINUSE or EACCES, try again max. 3 times.
diffstat:
1 file changed, 29 insertions(+)
src/lib/network.c | 29 +++++++++++++++++++++++++++++
diffs (39 lines):
diff -r a9e4221d5c0b -r ed6693fc06d6 src/lib/network.c
--- a/src/lib/network.c Thu Nov 29 07:21:58 2007 +0200
+++ b/src/lib/network.c Thu Nov 29 07:23:48 2007 +0200
@@ -128,6 +128,35 @@ static inline unsigned int sin_get_port(
return 0;
}
+
+#ifdef __FreeBSD__
+static int net_connect_ip_freebsd(const struct ip_addr *ip, unsigned int port,
+ const struct ip_addr *my_ip);
+
+int net_connect_ip(const struct ip_addr *ip, unsigned int port,
+ const struct ip_addr *my_ip)
+{
+ int fd, try;
+
+ for (try = 0;;) {
+ fd = net_connect_ip_freebsd(ip, port, my_ip);
+ if (fd != -1 || ++try == 5 ||
+ (errno != EADDRINUSE && errno != EACCES))
+ break;
+ /*
+ This may be just a temporary problem:
+
+ EADDRINUSE: busy
+ EACCES: pf may cause this if another connection used
+ the same port recently
+ */
+ }
+ return fd;
+}
+/* then some kludging: */
+#define net_connect_ip net_connect_ip_freebsd
+static
+#endif
int net_connect_ip(const struct ip_addr *ip, unsigned int port,
const struct ip_addr *my_ip)
More information about the dovecot-cvs
mailing list