summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/relay.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-02-26 11:59:49 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-02-26 11:59:49 +0000
commit52c6961ab92b67d820cf2103d3fa2ce0d5f99f16 (patch)
tree96171dc1bcdc50ada20f8144b0898bdfe1da1b5d /usr.sbin/relayd/relay.c
parentc1e466089148d8e00bcf277c18f13c056deea6d6 (diff)
re-use the retry value from table host entries for inbound relay
connections. the relay will retry to connect to the hosts for the specified number of times. this sounds bad, but is a useful "workaround" for unreliable backend servers...
Diffstat (limited to 'usr.sbin/relayd/relay.c')
-rw-r--r--usr.sbin/relayd/relay.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 94fe7cc317f..9bb2714fbb4 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.6 2007/02/26 11:24:26 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.7 2007/02/26 11:59:48 reyk Exp $ */
/*
* Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1297,6 +1297,7 @@ relay_from_table(struct session *con)
fatalx("relay_from_table: no active hosts, desynchronized");
found:
+ con->retry = host->retry;
con->out.port = table->port;
bcopy(&host->ss, &con->out.ss, sizeof(con->out.ss));
@@ -1368,8 +1369,17 @@ relay_connect(struct session *con)
con->out.port = rlay->dstport;
}
+ retry:
if ((con->out.s = relay_socket_connect(&con->out.ss, con->out.port,
rlay->proto)) == -1) {
+ if (con->retry) {
+ con->retry--;
+ log_debug("relay_connect: session %d: "
+ "forward failed: %s, %s",
+ con->id, strerror(errno),
+ con->retry ? "next retry" : "last retry");
+ goto retry;
+ }
log_debug("relay_connect: session %d: forward failed: %s",
con->id, strerror(errno));
return (-1);