diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-02-26 11:59:49 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-02-26 11:59:49 +0000 |
commit | 52c6961ab92b67d820cf2103d3fa2ce0d5f99f16 (patch) | |
tree | 96171dc1bcdc50ada20f8144b0898bdfe1da1b5d /usr.sbin/relayd | |
parent | c1e466089148d8e00bcf277c18f13c056deea6d6 (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')
-rw-r--r-- | usr.sbin/relayd/relay.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.conf.5 | 10 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 3 |
3 files changed, 22 insertions, 3 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); diff --git a/usr.sbin/relayd/relayd.conf.5 b/usr.sbin/relayd/relayd.conf.5 index 1ede18268b3..4b2fda7c381 100644 --- a/usr.sbin/relayd/relayd.conf.5 +++ b/usr.sbin/relayd/relayd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayd.conf.5,v 1.27 2007/02/25 09:04:59 jmc Exp $ +.\" $OpenBSD: relayd.conf.5,v 1.28 2007/02/26 11:59:48 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -369,6 +369,14 @@ headers and GET variables; see the .Sx PROTOCOLS section below. .El +.Pp +The optional host retry option will be used as a tolerance for failed +host connections, the connection will be retried for +.Ar number +more times, +see the +.Sx TABLES +section for details about host entries. .It Ic nat lookup When redirecting connections with an .Ar rdr diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index c9f30b15a7b..fa4017ab41f 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.31 2007/02/25 14:57:09 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.32 2007/02/26 11:59:48 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -337,6 +337,7 @@ struct session { struct timeval tv_start; struct timeval tv_last; int done; + int retry; struct evbuffer *log; void *relay; struct ctl_natlook *cnl; |