dovecot-1.0: Another try at FreeBSD connect() workaround
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 28 17:46:43 EET 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/78fd6c834a29
changeset: 5470:78fd6c834a29
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 28 17:46:37 2007 +0200
description:
Another try at FreeBSD connect() workaround
diffstat:
1 file changed, 29 insertions(+), 1 deletion(-)
src/lib/network.c | 30 +++++++++++++++++++++++++++++-
diffs (40 lines):
diff -r aad5ff16ce9a -r 78fd6c834a29 src/lib/network.c
--- a/src/lib/network.c Wed Nov 28 17:43:08 2007 +0200
+++ b/src/lib/network.c Wed Nov 28 17:46:37 2007 +0200
@@ -102,7 +102,35 @@ static inline unsigned int sin_get_port(
return 0;
}
-/* Connect to socket with ip address */
+#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